Function: toTimestamp()
toTimestamp(
date):Timestamp
Defined in: src/types/atproto-validators.ts:285
Creates a branded Timestamp from a Date object.
Parameters
date
Date
Date to convert to timestamp
Returns
Branded Timestamp (milliseconds since epoch)
Remarks
Timestamps are milliseconds since Unix epoch (January 1, 1970 00:00:00 UTC). This function provides type-safe conversion from JavaScript Date objects.
Example
const now = new Date();
const timestamp = toTimestamp(now);
console.log(timestamp); // 1699564800000
// Reconstruct Date
const reconstructed = new Date(timestamp);