Generate ISO 8601 timestamp: YYYYMMDDhhmmssSSS
npm install iso-timestamp
or
yarn add iso-timestamp
or
pnpm add iso-timestamp
-
date
: Custom date -
options:
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-07
👤 GloryWong
- Website: https://glorywong.com
- GitHub: @GloryWong
Give a ⭐️ if this project helped you!