A collection of date utility functions for formatting and comparing dates.
- Format dates with customizable patterns using
formatDate - Compare dates with
isAfterto check if one date is later than another - Compare dates with
isBeforeto check if one date is earlier than another - Support for both Date objects and string date inputs
- Customizable date separators
- Month and weekday abbreviations
- To ensure the security and integrity of your projects, please note that official PearPass packages are distributed exclusively through our GitHub organization.
- Any packages with similar names found on the npm registry or other third-party package managers are not affiliated with PearPass and should be strictly avoided. We recommend installing directly from this repository to ensure you are using the verified, open-source version.
npm install git+https://github.com/tetherto/pear-apps-utils-date.gitImport the functions you need:
import { formatDate, isAfter, isBefore } from '@tetherto/pear-apps-utils-date';// Basic formatting (default: yyyy-mm-dd)
formatDate(new Date('2023-05-15'));
// Output: '2023-05-15'
// Custom format
formatDate(new Date('2023-05-15'), 'dd-mm-yyyy');
// Output: '15-05-2023'
// Custom separator
formatDate(new Date('2023-05-15'), 'yyyy-mm-dd', '/');
// Output: '2023/05/15'
// With month abbreviation
formatDate(new Date('2023-05-15'), 'dd-mmm-yyyy');
// Output: '15-May-2023'
// With weekday abbreviation
formatDate(new Date('2023-05-15'), 'ddd-mm-dd');
// Output: 'Mon-05-15'// Check if a date is after another
isAfter('2023-01-02', '2023-01-01');
// Output: true
// Check if a date is before another
isBefore('2023-01-01', '2023-01-02');
// Output: trueThis package has no runtime dependencies.
- @tetherto/pearpass-app-mobile - A mobile app for PearPass, a password manager
- @tetherto/pearpass-app-desktop - A desktop app for PearPass, a password
- @tetherto/tether-dev-docs - Documentations and guides for developers
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.