https://github.com/jabercrombia/date-utility
A simple TypeScript utility function to format UTC date strings into "Month Day, Year" format.
https://github.com/jabercrombia/date-utility
date dateformat dateformatter typescript
Last synced: 10 months ago
JSON representation
A simple TypeScript utility function to format UTC date strings into "Month Day, Year" format.
- Host: GitHub
- URL: https://github.com/jabercrombia/date-utility
- Owner: jabercrombia
- Created: 2025-06-26T04:13:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-26T04:21:10.000Z (about 1 year ago)
- Last Synced: 2025-06-26T05:25:47.989Z (about 1 year ago)
- Topics: date, dateformat, dateformatter, typescript
- Language: TypeScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Date Utilities
This package provides simple TypeScript utility functions to format date strings into readable formats.
## 📦 Installation
You can install this utility directly from GitHub in your Next.js or TypeScript project.
Using **npm**:
```bash
npm install github:jabercrombia/date-utility
```
## Functions
### `formatDate(dateString: string): string`
Formats a date string into a short month and numeric year (e.g., "Jun 2025") using the US English locale.
**Parameters:**
- `dateString`: The date string to format (ISO 8601 or compatible).
**Returns:**
- Formatted date string with abbreviated month and year.
### `formatUTCToMonthDayYear(dateString: string): string`
Converts an ISO UTC date string to a human-readable format: "Month Day, Year".
**Example:** `"2025-06-06T00:00:00.000-05:00"` → `"June 6, 2025"`
**Parameters:**
- `dateString`: A valid ISO date string (UTC or with timezone offset).
**Returns:**
- A formatted string in the "Month Day, Year" format.
## Usage
```ts
import { formatDate, formatUTCToMonthDayYear } from "@jabercrombia/date-utils";
console.log(formatDate("2025-06-06T00:00:00.000-05:00")); // Jun 2025
console.log(formatUTCToMonthDayYear("2025-06-06T00:00:00.000-05:00")); // June 6, 2025
```
## Troubeshoot
If you are running into issues during the install run the below commands. It will remove the node_modules directory and package-lock.json. Then try rerunning the installation.
```bash
rm -rf node_modules
rm package-lock.json
```
## License
MIT License