Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A simple and flexible TypeScript package for formatting dates and times. The DateTimeFormatter
class allows you to format dates in various formats, handle both Date
objects and date strings, and includes features for easy integration into your projects.
Date
objects and date strings as inputTo install the package, you can use npm or yarn:
npm install datematic
(async () => {
const formatter = new DateTimeFormatter();
await formatter.init(); // Initialize the core if needed
const now = new Date();
console.log(formatter.formatUSDate(now)); // Output: MM/DD/YYYY
console.log(formatter.formatUSDate("2024-11-19")); // Output: 11/19/2024
console.log(formatter.formatDateDDMMYYYY(now)); // Output: DD-MM-YYYY
console.log(formatter.formatDateDDMMYYYY("2024-11-19")); // Output: 19-11-2024
console.log(formatter.formatDateYYYYMMDD(now)); // Output: YYYY-MM-DD
console.log(formatter.formatDateYYYYMMDD("2024-11-19")); // Output: 2024-11-19
console.log(formatter.formatTime(now)); // Output: HH:MM:SS
console.log(formatter.formatTime("2024-11-19T12:34:56")); // Output: 12:34:56
console.log(formatter.formatDateTime(now)); // Output: MM/DD/YYYY HH:MM:SS
})();
FAQs
Date and time formatting in a flash
We found that datematic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.