🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

re-date-parser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-date-parser

A lightweight library for parsing date strings into Date objects.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Date Parser

A lightweight library for parsing date strings into Date objects.

Installation

To install the package, run:

npm install re-date-parser

Usage

To use the library, require the date-parser module and call the parseDate function with a date string and format string:

const parseDate = require('re-date-parser');

const dateString = '2023-03-09T15:12:47.621Z';
const result = parseDate(dateString);

if (result) {
  console.log(`Parsed date: ${result.date.toISOString()}, using format: ${result.format}`);
} else {
  console.log('Failed to parse date.');
}

Supported formats

The library currently supports the following date formats:

  • YYYY/MM/DD
  • MM/DD/YYYY
  • DD/MM/YYYY
  • YYYY-MM-DD
  • MM-DD-YYYY
  • DD-MM-YYYY
  • YYYY/MM/DD HH:mm
  • MM/DD/YYYY HH:mm
  • DD/MM/YYYY HH:mm
  • YYYY-MM-DD HH:mm
  • MM-DD-YYYY HH:mm
  • DD-MM-YYYY HH:mm
  • YYYY/MM/DD HH:mm:ss
  • MM/DD/YYYY HH:mm:ss
  • DD/MM/YYYY HH:mm:ss
  • YYYY-MM-DD HH:mm:ss
  • MM-DD-YYYY HH:mm:ss
  • DD-MM-YYYY HH:mm:ss
  • YYYY/MM/DD HH:mm:ss.SSS
  • YYYY-MM-DDTHH:mm:ss.SSSZ
  • YYYY/MM/DD HH:mm:ss z
  • YYYY-MM-DD HH:mm:ss z
  • dd MMM yyyy HH:mm:ss.SSS z
  • MMM dd yyyy HH:mm:ss.SSS z
  • YYYY/MM/DD HH:mm:ss.SSS z
  • YYYY-MM-DD HH:mm:ss.SSS z

License

This library is licensed under the MIT License.

Keywords

date

FAQs

Package last updated on 10 Mar 2023

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