Skip to main content
Version: v0.19.1

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")
ยป "Mon Oct 31 00:08:10 2022"
๐Ÿš€ ยป Time.format(Time.unix(), "%a %b %e %H:%M:%S %Y")
ยป "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")
ยป 1647993600
๐Ÿš€ ยป Time.parse("2022-03-23", "%Y-%m-%d")
ยป 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()

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