Browse the docs

time

Returns the current unix time, or the unix time of a date you give.

Keyboard Maestro: TIME

Details #

time(year?, month?, day?, hour?, minute?, second?) takes 0 to 6 arguments and returns a number: unix time, the seconds since 1 January 1970 UTC.

  • With no arguments it is the current time, the same as now.

  • With arguments, the year is required; month and day default to 1, and hour and minute to 0. The date is read in the Mac's local time zone.

  • The sixth argument, seconds, is added on afterwards and may have decimals or be negative.

Year, month, day, hour and minute have their decimals cut off. Feed the result to year, month and the other date parts to take it apart again.

Parameters #

Takes 0 to 6 arguments. {{ time(text?, b?, c?, c?, c?, c?) }}

Examples #

time(2000, 1, 1, 0, 0, 0) - time(1999, 12, 31, 0, 0, 0)
→ 86400
time(2026, 10, 24, 9, 30) + 3600
→ 1792855800
time() - start
→ 1768491000
Sample variableValue
start0

Gotchas #

  • A date that doesn't exist stops the step: time() got a date that doesn't exist.

  • Because it uses local time, the same call gives different numbers in different time zones. For a time-zone-free number use jd or mjd, which take their date as UTC.

  • Anything that isn't a number is an error: time() needs a number, got text.