Skip to main content

$second

The $second operator extracts the second component from a date object (0-59).

Input

  • A single date object

Output

  • The second component of the date as an integer (0-59)

Examples

Extract Second from Date

{
  "$second": [
    {
      "$toDate": ["2023-01-15T10:30:45Z"]
    }
  ]
}
Result: 45

Extract Second from Field

{
  "$second": [
    {
      "$input": "event_date"
    }
  ]
}
Result: The second component (0-59) of the event_date field