iso-timestamp
v2.0.0
Published
Generate ISO 8601 timestamp: YYYYMMDDhhmmssSSS
Downloads
298
Maintainers
Readme
Generate ISO 8601 timestamp: YYYYMMDDhhmmssSSS
Install
npm install iso-timestampor
yarn add iso-timestampor
pnpm add iso-timestampAPI
timestamp(options?) or timestamp(date, options?)
date: Custom dateoptions:
excludeTime: Exclude time, i.e. hour, minute and second. Default: falseexcludeMillisecond: Exclude millisecond from time. Default: falseseparator: Separator among elements of the timestamp. Default: ''
import timestamp from 'iso-timestamp'
// Or import { timestamp } from 'iso-timestamp'
timestamp()
// return current timestamp: 202408070101123
timestamp({ excludeMillisecond: true })
// return timestamp with millisecond excluded: 202408070101
timestamp({ excludeTime: true })
// return timestamp with time excluded: 20240807
timestamp(new Date('2050-03-04T12:03:04.123'), { excludeMillisecond: true })
// return timestamp with custom Date: 20500304120304
timestamp({ separator: '-', excludeTime: true })
// return timestamp with custom separator: 2024-08-07Contributing
Contributions are welcome! If you have ideas, bug fixes, or improvements, please open an issue or submit a pull request on the GitHub repository.
Give a ⭐️ if this project helped you!
License
This project is licensed under the MIT License. See the LICENSE file for more details.
