1.0.8 • Published 4 years ago

date-ts v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

date-ts

Extra light package for working with dates

Installation

Use the package manager npm to install date-ts.

npm install date-ts

Usage

let date = require("date-ts");

// or

import date, { setDateFormat } from "date-ts";

// format date
date("Wed Sep 30 2020 14:44:09 GMT+0300").format();

// set global date format
setDateFormat("DD/MM/YYYY"); // default 'MM/DD/YYYY';

// with format different than global
date("Wed Sep 30 2020 14:44:09 GMT+0300").format("hh:mm"); // 2:44 PM
date("Wed Sep 30 2020 14:44:09 GMT+0300").format("HH:mm"); // 14:44
date("Wed Sep 30 2020 14:44:09 GMT+0300").format("DD-MM-YY"); // 30-09-20

//compare dates
date("Wed Sep 30 2020 14:44:09 GMT+0300").isDateBefore(
	"Wed Oct 7 2020 14:44:09 GMT+0300"
);
date("Wed Sep 30 2020 14:44:09 GMT+0300").isDateAfter(
	"Wed Oct 7 2020 14:44:09 GMT+0300"
);
date("Wed Sep 30 2020 14:44:09 GMT+0300").timeDifference(
	"Wed Oct 7 2020 14:44:09 GMT+0300",
	"hh:mm"
);

Info

For keepping this library extra light locales are omitted. In case you need to get a day of the week or write a full month name you can get number of the week day or a month number with this formatting and add month name or a weekday in your language

date("Wed Sep 30 2020 14:44:09 GMT+0300").format("dddd");
date("Wed Sep 30 2020 14:44:09 GMT+0300").format("MM");
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago