Home Contents | # clock.setDateTime | Date/Time | Core4 Lua Commands

## SYNOPSIS

1. clock.setDateTime(datetime)
2. clock.setDateTime(date, time)
3. clock.setDateTime(year, month, day, hour, minute[, second[, millisecond]])

## DESCRIPTION

This will set the system clock to the passed value and save it to the battery-backed hardware clock.

The first variant takes a datetime instance, the second variant uses separate date and time instances, while the last variant takes all values as numbers.

The system clock always runs in the UTC time zone. Before setting the system clock, convert any user input from local time to UTC by calling datetime:toUTC().

## RETURN VALUE

On success, returns true. On error, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

## BUGS

On Core4 OS, setting the hardware clock may block the current process up to one second, while the clock is synchronized.

## SEE ALSO

clock.currentDateTime, clock.newDateTime, clock.tzget, clock.tzset, datetime(), datetime:addDays, datetime:addMonths, datetime:addSecs, datetime:addYears, datetime:base90, datetime:date, datetime:day, datetime:daysTo, datetime:format, datetime:hour, datetime:isNull, datetime:isValid, datetime:isdst, datetime:minute, datetime:month, datetime:msec, datetime:offset, datetime:second, datetime:secsTo, datetime:set, datetime:setBase90, datetime:time, datetime:toLocal, datetime:toUTC, datetime:year, datetime:zone, tostring(datetime)