New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

datetime-next

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datetime-next

--- Next gen Date and Time manipulation library designed with performance in mind, it is **extremely lightweight**. It is about 3.5Kb minified and gzipped.

latest
Source
npmnpm
Version
1.2.6
Version published
Maintainers
1
Created
Source

DateTime Next

Next gen Date and Time manipulation library designed with performance in mind, it is extremely lightweight. It is about 3.5Kb minified and gzipped.

Does not use any static data such as localization files, everything comes from built in Intl object. However, this can be overridden if you provide your own Month names.

DateTime is designed to only operate on UTC date and time. It has however support for formatting date and time in user specified locale and timezone.

DateTime is specifically built as Mutable object, if you wish to use immutable object use DateTimeImmutable instead. Read more about this choice here

Zero dependencies.

npm

WARNING: API is not yet final

Requirements

Technically it should have no requirements, For node recommended version 8+. For browser, it's the existence of Intl object.

Docs

Read the docs here

Installation

For yarn:

yarn add datetime-next

For npm:

npm i datetime-next

For browser just include the script or import it via ES6 import statement.

Some examples

Imports:

// ES6 JS/Typescript style
import { DateTime } from 'datetime-next';
// OR
import { DateTime } from 'datetime-next/DateTime';

// require

const { DateTime } = require('datetime-next');

Basic usage:

const dt = new DateTime(); // Current datetime in UTC
dt.addHour(1); // Add one hour
dt.getString('YYYY-MM-DD'); // format date ex `2021-06-21`
dt.getString('HH:mm:ss'); // format time `15:25:41`

Format properties:

SymbolDescriptionExample
YYYear in 2 digit format21
YYYYYear in full format2021
MMonth digit not padded with zeros4
MMMonth padded to 2 digits04
MMMShort locale aware month nameDec
MMMMLong locale aware month nameDecember
dWeekday number5
ddWeekday locale aware narrow nameF
dddWeekday locale aware short nameFri
ddddWeekday locale aware short nameFriday
DDay of month not padded9
DDDay of month padded to 2 digits09
HHour in 24h format not padded7
HHHour in 24h format padded to 2 digits07
hHour in 12h format not padded7
hhHour in 12h format padded to 2 digits07
aMeridian locale aware in lowercaseam
AMeridian locale aware in uppercaseAM
mMinute not padded5
mmMinute padded to 2 digits05
sSecond not padded3
ssSecond padded to 2 digits03
SSSMilliseconds padded to 3 digits245
ZTimezone offset from UTC with colon+02:00
ZZTimezone offset from UTC without colon+02:00

Keywords

date

FAQs

Package last updated on 25 Apr 2022

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