Skip to main content

$toTimestamp

The $toTimestamp operator converts a date object to a timestamp.

Input

  • An array containing a date object and an optional granularity parameter (0 for seconds, 3 for milliseconds, 6 for microseconds, 9 for nanoseconds)

Output

  • The timestamp representation of the date object

Examples

Convert Date to Unix Timestamp (Seconds)

Result: 1673777400 (seconds since Unix epoch)

Convert Date to Milliseconds

Result: 1673777400000 (milliseconds since Unix epoch)

Field Value

Result: The timestamp in seconds since Unix epoch for the date_value field