Appearance
Function: getTimestamp()
ts
function getTimestamp(props?: GetTimestampProps): string;Defined in: src/utils/getTimestamp.ts:63
Generate a formatted UTC timestamp string.
Parameters
| Parameter | Type | Description |
|---|---|---|
props | GetTimestampProps | Options to control which date parts to include. |
Returns
string
The formatted timestamp string.
Examples
ts
// Default usage with current UTC date
const ts = getTimestamp(); // "2024-09-26-15-30-45"ts
// Custom separator
const ts = getTimestamp({ separator: '/' }); // "2024/09/26/15/30/45"ts
// Only year, month, and day
const ts = getTimestamp({
date: new Date('2023-12-01T08:22:33Z'),
includeHours: false,
includeMinutes: false,
includeSeconds: false,
}); // "2023-12-01"ts
// Only hours, minutes, and seconds
const ts = getTimestamp({
date: new Date('2023-12-01T08:22:33Z'),
includeYear: false,
includeMonth: false,
includeDay: false,
}); // "08-22-33"