Skip to content

Time

util.time : object

Date and time functions

Kind: static namespace of util

time.now() ⇒ number

Get the current UNIX timestamp in seconds.

Kind: static method of time

time.diff(compareto) ⇒ number

Get the number of seconds between now and the given Date or UNIX timestamp in seconds.

Kind: static method of time

Param Type
compareto number | Date

time.strtotime(str) ⇒ number

Parse a string date and return UNIX timestamp (in seconds).

Kind: static method of time

Param Type
str string

time.format(format, [timestamp]) ⇒ string

Take a Date or UNIX timestamp in seconds and format it to a string. Mostly compatible with the PHP date format codes.

Kind: static method of time

Param Type Default Description
format string "Y-m-d H:i:s", etc
[timestamp] number | Date now()

time.toDateString(timestamp) ⇒ string

Format a UNIX timestamp (in seconds) as a localized date string.

Kind: static method of time

Param Type
timestamp number

time.toTimeString(timestamp) ⇒ string

Format a UNIX timestamp (in seconds) as a localized time string.

Kind: static method of time

Param Type
timestamp number