npm.io
4.5.1 • Published 2 weeks ago

date-and-time

Licence
MIT
Version
4.5.1
Deps
0
Size
420 kB
Vulns
0
Weekly
0
Stars
188

date-and-time

date-and-time

CI Coverage npm

The simplest, most intuitive date and time library.

Installation

npm install date-and-time
import { format } from 'date-and-time';

format(new Date(), 'ddd, MMM DD YYYY');
// => Wed, Jul 09 2025
CommonJS
const { format } = require('date-and-time');

format(new Date(), 'ddd, MMM DD YYYY');
// => Wed, Jul 09 2025

CDN Usage

Via jsDelivr
<script type="module">
  import { format } from 'https://cdn.jsdelivr.net/npm/date-and-time/dist/index.js';

  console.log(format(new Date(), 'YYYY/MM/DD'));
</script>
Via unpkg
<script type="module">
  import { format } from 'https://unpkg.com/date-and-time/dist/index.js';

  console.log(format(new Date(), 'YYYY/MM/DD'));
</script>

Migration

Version 4.x has been completely rewritten in TypeScript and some features from 3.x are no longer compatible. The main changes are as follows:

  • The timezone and timespan plugins have been integrated into the main library
  • Tree shaking is now supported
  • Supports ES2021 and no longer supports older browsers

For details, please refer to migration.md.

API

For comprehensive documentation and examples, visit: GitHub Pages

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Keywords