Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@easepick/datetime

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@easepick/datetime

DateTime object for easepick.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@easepick/datetime

npm version

This package does not need to be installed if you are using @easepick/bundle.

DateTime library for easepick.

Documentation

https://easepick.com/packages/datetime

DateTime() constructor

Creates a JavaScript DateTime instance that represents a single moment in time.
Using: new DateTime(date, format, lang)

argumenttypedefault valuedescription
dateDate
string
number
nullDate object or date string or number (unix timestamp).
formatstring'YYYY-MM-DD'Required when you provide date argument as string. Must match a string value for proper parsing.
langstring'en-US'Affects month names (MMM, MMMM tokens).

You can omit all arguments and call new DateTime(). This will create a DateTime object represents the current date.

Methods

nameargumentsdescription
getWeek-Returns a week number of date
clone-Returns a copy of date
toJSDate-Returns Date object.
inArray(array, inclusivity)Find DateTime object in passed DateTime array.
isBetween(date1, date2, inclusivity)Check if a DateTime is between two other DateTime.
isBefore(date, unit)Check if a DateTime is before another DateTime. unit are day, month, year.
isSameOrBefore(date, unit)Check if a DateTime is before or the same as another DateTime. unit are day, month.
isAfter(date, unit)Check if a DateTime is after another DateTime.. unit are day, month, year.
isSameOrAfter(date, unit)Check if a DateTime is after or the same as another DateTime. unit are day, month.
isSame(date, unit)Check if a DateTime is the same as another DateTime. unit are day, month.
add(duration, unit)Mutates the original DateTime by adding unit. unit are day, month.
subtract(duration, unit)Mutates the original DateTime by subtracting unit. unit are day, month.
diff(date, unit)Returns diff between two DateTime. unit are day, month.
format(format, lang)Format output. See tokens format for format argument. lang affects month names (MMM, MMMM tokens).

Tokens format

Tokens are case-sensitive.

TokenOutput
Day of MonthD1 2 … 30 31
DD01 02 … 30 31
MonthM1 2 … 11 12
MM01 02 … 11 12
MMMJan Feb … Nov Dec
MMMMJanuary February … November December
YearYY70 71 … 29 30
YYYY1970 1971 … 2029 2030
Hours (24 hour time)H0 1 … 22 23
HH01 02 … 22 23
Minutesm1 2 … 58 59
mm01 02 … 58 59
Secondss1 2 … 58 59
ss01 02 … 58 59

FAQs

Package last updated on 22 Feb 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc