Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datematic

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datematic

Date and time formatting in a flash

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

DateTimeFormatter

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.

Features

  • Format dates to multiple formats:
    • MM/DD/YYYY
    • DD-MM-YYYY
    • YYYY-MM-DD
  • Format time to HH:MM:SS
  • Combine date and time formatting
  • Accepts both Date objects and date strings as input

Installation

To install the package, you can use npm or yarn:

npm install datematic

Usage

(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
})();

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc