Socket
Socket
Sign inDemoInstall

@types/moment

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/moment

TypeScript definitions for Moment.js 2.11.1


Version published
Weekly downloads
318K
increased by5.22%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @types/moment?

@types/moment provides TypeScript type definitions for the Moment.js library, which is used for parsing, validating, manipulating, and formatting dates.

What are @types/moment's main functionalities?

Parsing Dates

This feature allows you to parse dates from strings into Moment.js objects, which can then be manipulated or formatted as needed.

const moment = require('moment');
const date = moment('2023-10-01');
console.log(date.format('YYYY-MM-DD'));

Formatting Dates

This feature allows you to format Moment.js date objects into human-readable strings using various format tokens.

const moment = require('moment');
const date = moment();
console.log(date.format('MMMM Do YYYY, h:mm:ss a'));

Manipulating Dates

This feature allows you to manipulate dates by adding or subtracting time units such as days, months, or years.

const moment = require('moment');
let date = moment();
date = date.add(7, 'days');
console.log(date.format('YYYY-MM-DD'));

Validating Dates

This feature allows you to validate whether a given date string conforms to a specified format.

const moment = require('moment');
const isValid = moment('2023-10-01', 'YYYY-MM-DD', true).isValid();
console.log(isValid);

Other packages similar to @types/moment

Readme

Source

Installation

npm install --save @types/moment

Summary

This package contains type definitions for Moment.js 2.11.1 (https://github.com/timrwood/moment).

Details

Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/moment

Additional Details

  • Last updated: Tue, 02 Aug 2016 15:42:58 GMT
  • File structure: UMD
  • Library Dependencies: none
  • Module Dependencies: none
  • Global values: moment

Credits

These definitions were written by Michael Lakerveld https://github.com/Lakerfield, Aaron King https://github.com/kingdango, Hiroki Horiuchi https://github.com/horiuchi, Dick van den Brink https://github.com/DickvdBrink, Adi Dahiya https://github.com/adidahiya, Matt Brooks https://github.com/EnableSoftware, Gal Talmor https://github.com/galtalmor.

FAQs

Last updated on 02 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc