Skip to main content
Version: Next

Time

Module Function

format(INTEGER, STRING)

Returns STRING

Formats the given unix timestamp with the given layout

Go date and time formats are natively supported. You can also use some but not all formats present in many other languages which are not fully supported. Take a look at the source to see which formatters are supported.

Time.format(Time.unix(), "Mon Jan _2 15:04:05 2006")
Time.format(Time.unix(), "%a %b %e %H:%M:%S %Y")
Output
"Mon Oct 31 00:08:10 2022"
"Mon Oct 31 00:28:43 2022"

parse(STRING, STRING)

Returns STRING

Parses a given string with the given format to a unix timestamp.

Go date and time formats are natively supported. You can also use some but not all formats present in many other languages which are not fully supported. Take a look at the source to see which formatters are supported.

Time.parse("2022-03-23", "2006-01-02")
Time.parse("2022-03-23", "%Y-%m-%d")
Output
1647993600
1647993600

sleep(INTEGER)

Returns NIL

Stops the RocketLang routine for at least the stated duration in seconds

Time.sleep(2)

unix()

Returns INTEGER

Returns the current time as unix timestamp

Time.unix()
Output
1668788502

Properties

NameValue
ANSICMon Jan _2 15:04:05 2006
Kitchen3:04PM
Layout01/02 03:04:05PM '06 -0700
RFC1123Mon, 02 Jan 2006 15:04:05 MST
RFC1123ZMon, 02 Jan 2006 15:04:05 -0700
RFC33392006-01-02T15:04:05Z07:00
RFC3339Nano2006-01-02T15:04:05.999999999Z07:00
RFC82202 Jan 06 15:04 MST
RFC822Z02 Jan 06 15:04 -0700
RFC850Monday, 02-Jan-06 15:04:05 MST
RubyDateMon Jan 02 15:04:05 -0700 2006
StampJan _2 15:04:05
StampMicroJan _2 15:04:05.000000
StampMilliJan _2 15:04:05.000
StampNanoJan _2 15:04:05.000000000
UnixDateMon Jan _2 15:04:05 MST 2006