
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Utilities for working with JavaScript Dates. Plays nicely with TimezoneJS.
Utilities for working with JavaScript Dates. Plays nicely with TimezoneJS. Includes:
strftime
– formats dates based on a string
input.add
– increments a date the desired number of
units.diff
– gets the time difference between two
dates.strftime(dt, formatString);
dt (Object/Date or Number) – The date to be formatted, JS Date or numeric timestamp.
formatString (String) – Indicates how the date is to be formatted.
Formats a date or time according to a given format string – identical to the strftime function found in many scripting languages such as Perl, Ruby, or PHP.
The format string may include the following specifiers:
var bd = new Date('12/27/1968');
strftime(bd, 'My birthdate was %A, %B %e, %Y.');
=> 'My birthdate was Friday, December 27, 1968.'
var dt = new Date('10/01/2112');
strftime(dt, 'I found a guitar in %B of %Y.');
=> 'I found a guitar in October of 2112.'
someHash.add(someKey, value);
dt (Object/Date or Number) – The date to be incremented/decremented.
interval (constant, see dateParts) – the unit (e.g., days, weeks, hours, minutes) of time that the date is to be incremented/decremented.
count (Number) – The number of the desired units to increment/decrement the date.
Increments/decrements a date by some number of a specified unit of time (e.g., adds three weeks, subtracts eight hours).
var dateParts = dateParts;
// Add 10 years
var bd = new Date('12/27/1968');
bd = add(bd, dateParts.YEAR, 10);
=> Wed Dec 27 1978 00:00:00 GMT-0600 (CST)
// Subtract 2 hours
var dt = new Date(2112, 9, 1, 12, 45);
dt = add(dt, dateParts.HOUR, -2);
=> Sat Oct 01 2112 10:45:00 GMT-0500 (CDT)
diff(dtA, dtB, interval);
dtA, dbB (Object/Date or Number) – The dates to be compared.
interval (constant, see dateParts) – the unit (e.g., days, weeks, hours, minutes) of time to use when comparing the two dates.
Returns the time difference between two dates, measured in a specified unit of time (e.g., how many days between, how many hours between, how many weeks between).
var dateParts = dateParts;
// Number of months between these dates
var dt1 = new Date('01/01/2112');
var dt2 = new Date('10/01/2112');
var diff = diff(dt1, dt2, dateParts.MONTH);
=> 9
// Number of weekdays between these dates
var dt1 = new Date('09/11/2007');
var dt2 = new Date('09/28/2007');
var diff = diff(dt1, dt2, dateParts.WEEKDAY);
=> 13
FAQs
Utilities for working with JavaScript Dates. Plays nicely with TimezoneJS.
The npm package date-fu receives a total of 4 weekly downloads. As such, date-fu popularity was classified as not popular.
We found that date-fu demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.