@biswarup598/date-parser
v1.0.0
Published
This is a package that performs date parsing into more readable format.
Downloads
5
Readme
📅 date-parser
A lightweight and simple JavaScript utility function to parse raw date strings into readable date and time formats based on locale.
✨ Features
- Converts any valid date string or timestamp into a localized date and time.
- Supports custom locales (default:
en-IN). - Returns both date and time in a user-friendly format.
📦 Installation
npm install @biswarup598/date-parserReplace
date-parser-litewith your actual package name if it's different.
🚀 Usage
import { dateParser } from "@biswarup598/date-parser";
const [date, time] = dateParser("2025-04-04T15:30:00Z");
console.log(date); // "04/04/25"
console.log(time); // "09:00 PM" (based on locale)🔧 API
dateParser(rawDate, locale?)
| Parameter | Type | Default | Description |
|------------|----------|---------|----------------------------------------------|
| rawDate | string | – | A valid date string or timestamp. |
| locale | string | en-IN | Optional. Locale string for formatting. |
Returns
An array:
[formattedDate, formattedTime]formattedDate: A locale-formatted date string.formattedTime: A locale-formatted 12-hour time string.
🌐 Examples
dateParser("2025-01-15T10:45:00Z", "en-US"); // ["01/15/25", "03:45 AM"]
dateParser(Date.now()); // ["04/04/25", "09:00 PM"]📄 License
MIT
Let me know if you want to add badges, TypeScript support details, or publish instructions!
