1.0.7 • Published 9 months ago

format-with-timezone v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Format With Timezone

A simple utility to format date strings in specific time zones using the format-with-timezone package.

Installation

To install the package, run:

npm install format-with-timezone


#codepart


const formatDateWithTimezone = require('format-with-timezone');

// Example date string
const dateString = '2024-10-27T04:00:00Z';

// Format the date to a specified timezone and format

const fullDate = formatDateWithTimezone(dateString, 'Asia/Kolkata', 'full');
console.log(fullDate); // Output: "Sun, Oct 27, 2024, 09:30 AM"


const dateOnly = formatDateWithTimezone('2024-10-27T04:00:00Z', 'Asia/Kolkata', 'date-only');
console.log(dateOnly); // Output: "Sun, Oct 27, 2024"

const timeOnly = formatDateWithTimezone('2024-10-27T04:00:00Z', 'Asia/Kolkata', 'time-only');
console.log(timeOnly); // Output: "09:30 AM"

const longDate = formatDateWithTimezone('2024-10-27T04:00:00Z', 'Asia/Kolkata', 'long-date');
console.log(longDate); // Output: "Sunday, October 27, 2024"

const shortFormat = formatDateWithTimezone('2024-10-27T04:00:00Z', 'Asia/Kolkata', 'short');
console.log(shortFormat); // Output: "2024-10-27"

const monthDate = formatDateWithTimezone('2024-10-27T04:00:00Z', 'Asia/Kolkata', 'month-date');
console.log(monthDate); // Output: "Oct 27"

const separateDetails=formatDateWithTimezone('2024-10-28T15:30:00Z', 'Asia/Kolkata','month-year-date');
console.log(separateDetails); // Output: { month: 'Oct', year: 2024, date: '28' }
1.0.7

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago