Returns today's date in the given format
For example:
import * as date from "datr.js";
//This is just an example format
const dateNow = date.get("YY MMMM DD dddd hhhh:mmmm:ssss:s ZZZZ");
//Expected output 2022 June 6 Monday 19:25:12:352 +02:00
console.log(dateNow);
(Scroll down for further information)
Returns the day on which a particular date fell
For example:
import * as date from "datr.js";
//This is just an example
const day = date.getDayName(1, 1, 1998);
//Expected output: Thursday
console.log(day);
Returns the length of the given month or if there's no given month returns the length of the current month.
For example:
import * as date from "datr.js";
//This is just an example
const monthLength = date.getMonthLength("January");
//Expected output: 31
console.log(monthLength);
(Instead of "January" you can also use "january" or "1")
Returns the date after the specified days have elapsed
For example:
import * as date from "datr.js";
//It's 6th of june now
const days = date.daysFromNow(20);
//Expected output: { day: 26, month: 6, year: 2022 }
console.log(days);
Checks if the given year is leap year or not, or if there's no given year it returns if the current year is leap year or not.
For example:
import * as date from "datr.js";
const days = date.isLeapYear(2024);
//Expected output: true
console.log(days);
Format types:
Y: The first two numbers of the year (2022 --> 22)
YY: The whole year (2022)
M: The month in numbers (5 --> 5, 12 --> 12)
MM: A zero and the month in numbers (5 --> 05, 12 --> 12)
MMM: The short name of the month (December --> Dec)
MMMM: The whole name of the month (December --> December)
D: The date (1 -->, 12 --> 12)
DD: A zero and the date (1 --> 01, 12 --> 12)
d: The day of the week in numbers (Monday --> 1)
dd: The first two letters of the day (Monday --> Mo)
ddd: The first three letters of the day (Monday --> Mon)
dddd: The day of the week (Monday --> Monday)
h: The current hour in 12 hour format (14:00 --> 2:00)
hh: The current hour in 12 hour format with a zero before the hour (14:00 --> 02:00)
hhh: The current hour in 24 hour format (1:00 --> 1:00)
hhhh: The current hour in 24 hour format with a zero before the hour (1:00 --> 01:00)
m: The decimal place value of the current minute (12 --> 1)
mm: The some place value of the current minute (12 --> 2)
mmm: The current minute (12 --> 12, 8 --> 8)
mmmm: The current minute and a zero (12 --> 12, 8 --> 08)
s: Milliseconds
ss: The decimal place value of the current second (12 --> 1)
sss: The some place value of the current second (12 --> 2)
ssss: The current second and a zero (8 --> 08, 12 --> 12)
sssss: The whole second (12 --> 12, 8 --> 8)
Z: The current time zone (+2)
ZZ: The current timezone with a zero (+02)
ZZZ: The current timezone with a zero and minutes (+0200)
ZZZZ: The current timezone with a zero, minutes and a colon (+02:00)