timestamp.as_unix_seconds
Supported in:
timestamp.as_unix_seconds(timestamp [, time_zone])
Description
This function returns an integer representing the number of seconds past a Unix epoch for the given timestamp string.
timestampis a string representing a valid epoch timestamp. The format needs to be%F %T.time_zoneis optional and is a string representing a time zone. If omitted, the default isGMT. You can specify time zones using string literals. The options are as follows:- The TZ database name, for example
America/Los_Angeles. For more information, see the list of tz database time zones on Wikipedia. - The time zone offset from UTC, in the format
(+|-)H[H][:M[M]], for example: "-08:00".
- The TZ database name, for example
Here are examples of valid time_zone specifiers, which you can pass as the second argument to time extraction functions:
"America/Los_Angeles", or "-08:00". ("PST" is not supported)
"America/New_York", or "-05:00". ("EST" is not supported)
"Europe/London"
"UTC"
"GMT"
Param data types
STRING, STRING
Return type
INT
Code samples
Example 1
Valid epoch timestamp
timestamp.as_unix_seconds("2024-02-22 10:43:00") = 1708598580
Example 2
Valid epoch timestamp with the America/New_York time zone
timestamp.as_unix_seconds("2024-02-22 10:43:00", "America/New_York") = 1708616580