Home  Contents

clock.currentTime

Date/Time Core4 Lua Commands

SYNOPSIS

  1. time = clock.currentTime()
  2. time = clock.newTime([hour[, minute[, second[, millisecond]]]])
  3. time = clock.newTime([str)

DESCRIPTION

Both functions create a new time instance. clock.currentTime() initializes the instance from the current system time, while clock.newTime() initializes from an arbitrary value. Parameters that are missing from the clock.newTime() call are initialized as zero.

Particularly, the third form takes a string str encoded in ISO8601 format (a 24h format) "HH:MM:SS". This is the same format as returned by tostring(time).

RETURN VALUE

Returns a new time instance.

NOTES

The system clock runs in the UTC time zone. If you need the local time, please use clock.newDateTime() and convert to local time using datetime:toLocal().

EXAMPLE

>  > 
t = clock.newTime(12,34,56) print (t)
12:34:56
>  > 
t = clock.newTime("12:34:56") print (t:hour(), t:minute(), t:second())
12 34 56

SEE ALSO