Skip to content

date-and-timeThe simplest, most intuitive date and time library

Modern TypeScript library for date manipulation with full ES Modules support

date-and-time

Quick Example โ€‹

typescript
import { format, parse, addDays } from 'date-and-time';
import ja from 'date-and-time/locales/ja';
import Tokyo from 'date-and-time/timezones/Asia/Tokyo';

const now = new Date();

// Basic formatting
format(now, 'YYYY/MM/DD HH:mm:ss');
// => 2025/08/23 14:30:45

// Localized formatting
format(now, 'YYYYๅนดMๆœˆDๆ—ฅ(ddd)', { locale: ja });
// => 2025ๅนด8ๆœˆ23ๆ—ฅ(้‡‘)

// Timezone-aware formatting
format(now, 'YYYY-MM-DD HH:mm:ss [JST]', { timeZone: Tokyo });
// => 2025-08-23 23:30:45 JST

// Parsing
const date = parse('2025/08/23 14:30:45', 'YYYY/MM/DD HH:mm:ss');
console.log(date)

// Date arithmetic
const futureDate = addDays(now, 7);
console.log(format(futureDate, 'YYYY/MM/DD'));

Key Features in v4.x โ€‹

  • ๐Ÿ”„ Complete TypeScript rewrite with enhanced type safety
  • ๐Ÿ“ฆ Tree-shaking support for better bundle optimization
  • ๐ŸŒ Integrated timezone and timespan plugins into the core library
  • ๐ŸŽฏ Modern JavaScript targeting ES2021 (Node.js โ‰ฅ18 required)
  • ๐Ÿ”ง Enhanced API with options objects instead of boolean flags
  • ๐Ÿ“š Improved locale handling with per-function locale specification

Browser & Environment Support โ€‹

  • Node.js: 18+
  • Browsers: Chrome 85+, Firefox 78+, Safari 14+, Edge 85+
  • Module Systems: ES Modules, CommonJS
  • TypeScript: 4.5+

Installation โ€‹

bash
npm install date-and-time
bash
yarn add date-and-time
bash
pnpm add date-and-time

Community โ€‹

Released under the MIT License.