@d1g1tal/date-time-js

2.1.1 • Public • Published

DateTime

JavaScript wrapper for Date object

Installation

npm install @d1g1tal/date-time-js

Usage

import DateTime from '@d1g1tal/date-time-js';

const dateTime = new DateTime();

// Local time
console.log(dateTime.format(DateTime.Pattern.ISO_DATE_TIME)); // 2023-03-28T11:43:58.130GMT-4:00
// or
console.log(dateTime.format('YYYY-MM-DD[T]HH:mm:ss.SSSZ')); // 2023-03-28T11:43:58.130GMT-4:00

// UTC time
console.log(dateTime.utc().format(DateTime.Pattern.ISO_DATE_TIME)); // 2023-03-28T15:43:58.130Z

API

DateTime

Constructor

new DateTime();

Methods

format
dateTime.format(DateTime.Pattern.ISO_DATE_TIME);
utc
dateTime.utc();
add
dateTime.add(DateTime.Unit.DAY, 1);
subtract
dateTime.subtract(DateTime.Unit.DAY, 1);
get
dateTime.get(DateTime.Unit.DAY);
set
dateTime.set(DateTime.Unit.DAY, 1);
isLeapYear
dateTime.isLeapYear();

Package Sidebar

Install

npm i @d1g1tal/date-time-js

Weekly Downloads

0

Version

2.1.1

License

MIT

Unpacked Size

927 kB

Total Files

36

Last publish

Collaborators

  • d1g1tal