adam-datetime
v1.0.0
Published
Native Date has not enough useful mechanics, so this package is about it. Time delta, formatting and ENGLISH words.
Downloads
9
Readme
Datetime
[Javascript]
Datetime is like native Date but improved
const date = new Datetime;
console.log(date.toString());
// Sun Jan 20 2019 13:35:48 GMT+0400 (Samara Standard Time)
date.add(5).years().and(1).day();
console.log(date.format('c'));
// 2024-01-21T09:35:48+00:00
console.log(date.format('r'));
// Mon, 21 Jan 2024 09:35:48 +0000
console.log(date.format('Y-m-d H:i:s'));
// 2024-01-21 09:35:48
console.log(date.format('d/m/y g:i'));
// 21/01/24 9:35
Get started
const date = new Datetime()
date.getWeek(); // Returns the week number
date.getWeekYear(); // Returns the full year by week
date.isLeap(); // Returns bool true or false if years is leap
date.getDaysInMonth(); // Returns how many days in month (31/30/29/28)
date.getDayPeriod(); // Returns 'am' or 'pm'
date.getInternetTime(); // Returns 000 to 999 Swatch internet time
date.offset(hours); // Set timezone offset in hours (have effect on Datetime methods) may be float
date.getGMTOffset(separator=''); // Returns ±00${separator}00 GMT offset (the one you set by .offset)
date.format(pattern=''); // Returns formatted date. Patterns could be found at http://php.net/manual/en/function.date.php
// Supports all patterns except for I and T letters
Have questions, improvements or just wanna talk?
Me at discord: Adam Bright#8084