dtStamp
@pencroff-lab/kore / format_dt
Compact, sortable date/time stamps for file names, log prefixes, and IDs.
dtStamp() produces strings like 20260317_143012 (default) or
2026-03-17_14:30:12 (readable mode). Supports UTC/local timezone,
date-only/time-only parts, optional milliseconds, and a configurable
delimiter — all controlled via a single DtStampOptions object.
See
format_dt.examples.test.ts for usage patterns
Interfaces
DtStampOptions
Defined in: utils/format_dt.ts:16
Options for configuring dtStamp() output format.
Properties
delimiter?
optionaldelimiter:string
Defined in: utils/format_dt.ts:21
Character(s) between date/time segments.
Default
"_"ms?
optionalms:boolean
Defined in: utils/format_dt.ts:26
Include milliseconds in the time portion.
Default
falseparts?
optionalparts:"date"|"datetime"|"time"
Defined in: utils/format_dt.ts:36
Which parts of the stamp to include.
"datetime"– full stamp (date + time)"date"– date only"time"– time only
Default
"datetime"readable?
optionalreadable:boolean
Defined in: utils/format_dt.ts:38
Use human-readable separators (dashes, colons).
Default
falsetz?
optionaltz:"utc"|"local"
Defined in: utils/format_dt.ts:28
Timezone for date/time components.
Default
"utc"Functions
dtStamp()
dtStamp(
date?,options?):string
Defined in: utils/format_dt.ts:51
Format a Date into a filesystem/log-safe timestamp string.
Produces compact, sortable stamps suitable for file names, log prefixes, and anywhere a human-readable but machine-sortable date/time is needed.
Parameters
date?
Date, Unix ms timestamp, or null (defaults to now)
number | Date | null
options?
Formatting options
Returns
string
Formatted timestamp string