Reference

Timestamp

Now

Output A timestamp instance with the current local date and time.

Signature

time_now(): Timestamp

Example

time_now() // returns the current timestamp

From ISO

Input A string representation of a timestamp in ISO 8601 format.
Output A timestamp instance.

Signature

time_fromIso(a: String): Timestamp

Example

time_fromIso("2024-01-15T10:30:00.000Z") // returns a timestamp

From Epoch

Input The number of milliseconds since the Unix epoch.
Output A timestamp instance.

Signature

time_fromEpoch(a: Number): Timestamp

Example

time_fromEpoch(1704067200000) // returns a timestamp

To ISO

Input A timestamp instance.
Output A string representation of the timestamp in ISO 8601 format.

Signature

time_toIso(a: Timestamp): String

Example

time_toIso(time_now()) // returns the ISO 8601 string

To Epoch

Input A timestamp instance.
Output The number of milliseconds since the Unix epoch.

Signature

time_toEpoch(a: Timestamp): Number

Example

time_toEpoch(time_now()) // returns the epoch time in milliseconds

Format

Input A timestamp and a format pattern string.
Output A string representation of the timestamp in the specified format.

Signature

time_format(a: Timestamp, b: String): String

Example

time_format(time_now(), "yyyy-MM-dd") // returns "2024-01-15"

Year

Input A timestamp instance.
Output The year of the timestamp.

Signature

time_year(a: Timestamp): Number

Example

time_year(time_fromIso("2024-01-15T10:30:00.000Z")) // returns 2024

Month

Input A timestamp instance.
Output The month of the timestamp (1-12).

Signature

time_month(a: Timestamp): Number

Example

time_month(time_fromIso("2024-01-15T10:30:00.000Z")) // returns 1

Day

Input A timestamp instance.
Output The day of the timestamp (1-31).

Signature

time_day(a: Timestamp): Number

Example

time_day(time_fromIso("2024-01-15T10:30:00.000Z")) // returns 15

Day of Week

Input A timestamp instance.
Output The day of the week (1-7, where 1 is Monday).

Signature

time_dayOfWeek(a: Timestamp): Number

Example

time_dayOfWeek(time_now()) // returns 1-7 (Monday=1)

Day of Year

Input A timestamp instance.
Output The day of the year (1-366).

Signature

time_dayOfYear(a: Timestamp): Number

Example

time_dayOfYear(time_now()) // returns 1-366

Hour

Input A timestamp instance.
Output The hour of the timestamp (0-23).

Signature

time_hour(a: Timestamp): Number

Example

time_hour(time_fromIso("2024-01-15T10:30:00.000Z")) // returns 10

Minute

Input A timestamp instance.
Output The minute of the timestamp (0-59).

Signature

time_minute(a: Timestamp): Number

Example

time_minute(time_fromIso("2024-01-15T10:30:00.000Z")) // returns 30

Second

Input A timestamp instance.
Output The second of the timestamp (0-59).

Signature

time_second(a: Timestamp): Number

Example

time_second(time_fromIso("2024-01-15T10:30:45.000Z")) // returns 45

Millisecond

Input A timestamp instance.
Output The millisecond of the timestamp (0-999).

Signature

time_millisecond(a: Timestamp): Number

Example

time_millisecond(time_fromIso("2024-01-15T10:30:00.500Z")) // returns 500

Compare

Input Two timestamp instances.
Output 1 if the first timestamp is bigger than the second. -1 if it is the smaller. 0 if they are equal.

Signature

time_compare(a: Timestamp, b: Timestamp): Number

Example

time_compare(time_fromIso("2024-02-01T00:00:00Z"), time_fromIso("2024-01-01T00:00:00Z")) // returns 1

Is Before

Input Two timestamps.
Output True if the first timestamp is before the second, false otherwise.

Signature

time_isBefore(a: Timestamp, b: Timestamp): Boolean

Example

time_isBefore(yesterday, time_now()) // returns true

Is After

Input Two timestamps.
Output True if the first timestamp is after the second, false otherwise.

Signature

time_isAfter(a: Timestamp, b: Timestamp): Boolean

Example

time_isAfter(time_now(), yesterday) // returns true

Add

Input A timestamp and a duration.
Output A new timestamp with the duration added.

Signature

time_add(a: Timestamp, b: Duration): Timestamp

Example

time_add(time_now(), duration_fromHours(2)) // returns timestamp 2 hours from now

Subtract

Input A timestamp and a duration.
Output A new timestamp with the duration subtracted.

Signature

time_subtract(a: Timestamp, b: Duration): Timestamp

Example

time_subtract(time_now(), duration_fromDays(1)) // returns timestamp 1 day ago

Between

Input Two timestamps.
Output The duration between the two timestamps.

Signature

time_between(a: Timestamp, b: Timestamp): Duration

Example

time_between(t1, t2) // returns the duration between t1 and t2

Is Leap Year

Input A year as a number.
Output True if the year is a leap year, false otherwise.

Signature

time_isLeapYear(a: Number): Boolean

Example

time_isLeapYear(2024) // returns true