A comprehensive library for date and time manipulation in JavaScript. Provides utilities for parsing, validating, and formatting dates and times.
npm install @atlassian/date-timeimport * as dateTime from "@atlassian/date-time";dateTime.parse("2024-01-01");
// → Mon Jan 01 2024 00:00:00 GMT+0000
dateTime.validate("2024-01-01");
// → true
dateTime.getDatePattern("en-US");
// → "mm/dd/yyyy"dateTime.formatPlainDate(new Date());
// → "2024-01-01"
dateTime.formatPlainTime(new Date());
// → "12:00:00"
dateTime.formatPlainDateTime(new Date());
// → "2024-01-01T12:00:00"dateTime.formatNumericDate(new Date(), "en-US");
// → "1/1/2024"
dateTime.formatDate(new Date(), "en-US");
// → "Jan 1, 2024"
dateTime.formatTime(new Date(), "en-US");
// → "12:00:00 PM"
dateTime.formatDateTime(new Date(), "en-US");
// → "Jan 1, 2024, 12:00:00 PM"
dateTime.formatDateTimeByOptions({ second: undefined }, new Date(), "en-US");
// → "Jan 1, 2024, 12:00 PM"dateTime.formatDuration(new Date(2024, 0, 1), new Date(2024, 0, 2), "en-US");
// → "1 day 1 hour 1 minute 1 second"
dateTime.formatDurationByOptions({ unitDisplay: "narrow" }, new Date(2024, 0, 1), new Date(2024, 0, 2), "en-US");
// → "1d 1h 1m 1s"npm run typecheck # Type checking
npm run lint # ESLint + Prettier check
npm run format # Auto-fix lint + format
npm test # Run unit tests
npm run build # Build for production
npm run checks # Run all checksContributions to Date Time API are welcome! Please see CONTRIBUTING.md for details.
Copyright (c) 2024 Atlassian US., Inc. Apache 2.0 licensed, see LICENSE file.
