date-and-time is the simplest, most intuitive date and time library for JavaScript and TypeScript. Built from the ground up with modern development practices, it provides a comprehensive set of tools for date manipulation, formatting, parsing, and timezone handling.
- Written entirely in TypeScript with ES2021 target
- Tree-shakable modules for optimal bundle size
- Zero dependencies for core functionality
- Full ES Modules and CommonJS support
- Support for 40+ locales with native month/day names
- Multiple calendar systems (Gregorian, Buddhist)
- Numeral systems (Latin, Arabic, Bengali, Myanmar)
- Timezone-aware formatting and parsing
- Full TypeScript support with comprehensive type definitions
- IntelliSense support in modern editors
- Consistent API design across all functions
- Extensive documentation and examples
- Node.js 18+ support
- Modern browser compatibility (Chrome 85+, Firefox 78+, Safari 14+)
- Comprehensive test suite with high coverage
- Battle-tested in production environments
format()- Convert Date objects to formatted stringsparse()- Parse date strings into Date objectscompile()- Precompile format strings for performancepreparse()- Parse date strings and return intermediate resultsisValid()- Validate date string formatstransform()- Transform date strings between different formats
addYears(),addMonths(),addDays()- Date additionaddHours(),addMinutes(),addSeconds(),addMilliseconds()- Time additionsubtract()- Calculate time differences with Duration objects
isLeapYear()- Check if a year is a leap yearisSameDay()- Check if two dates are on the same day
- Timezone Support - Comprehensive timezone data from timezonedb
- Locale Support - 40+ languages with native formatting
- Plugin System - Extend formatters and parsers
- Duration Objects - Rich time difference calculations
Version 4.x represents a complete rewrite with significant improvements:
- TypeScript-first development approach
- Integrated plugins - timezone and timespan functionality built-in
- New API signatures - options objects replace boolean parameters
- Modern JavaScript - ES2021 features throughout
- Reduced bundle size with tree-shaking
- Expanded language support - Now supporting 40+ locales
- Improved TypeScript inference and completion
- Comprehensive documentation with live examples
import { format, parse } from 'date-and-time';
import ja from 'date-and-time/locales/ja';
import Tokyo from 'date-and-time/timezones/Asia/Tokyo';
// Core functionality
const date = new Date();
const formatted = format(date, 'YYYY/MM/DD');
// Localized formatting
const localized = format(date, 'YYYY年M月D日', { locale: ja });
// Timezone-aware operations
const tokyoTime = format(date, 'YYYY-MM-DD HH:mm:ss', { timeZone: Tokyo });
// Or using IANA timezone name string (New in v4.2.0)
const tokyoTime2 = format(date, 'YYYY-MM-DD HH:mm:ss', { timeZone: 'Asia/Tokyo' });- Node.js 18.0.0+ (LTS recommended)
- Full ES Modules support
- CommonJS compatibility
| Browser | Minimum Version |
|---|---|
| Chrome | 85+ |
| Firefox | 78+ |
| Safari | 14+ |
| Edge | 85+ |
- ES Modules (
.mjs,type: "module") - CommonJS (
.cjs, traditional Node.js) - TypeScript (4.5+)
- Bundlers (Webpack, Rollup, Vite, etc.)
Ready to start using date-and-time? Continue to the Installation Guide to set up the library in your project.