Home Contents | # Date/Time Conversion | Date/Time | Core4 Lua Commands

## SYNOPSIS

1. dt = datetime:toLocal()
2. dt = datetime:toUTC()

## DESCRIPTION

datetime:toLocal converts a date/time from the UTC time zone to the local time, while datetime:toUTC does the reverse.

## RETURN VALUE

Both functions return another datetime instance with the converted value.

## NOTES

The system clock always runs on UTC time and does not know anything about local time zones.

Use the provided functions to convert between UTC and local time. It is recommended to do all internal date/time processing using UTC and only convert to local time when displaying a date/time to a user. That way, the software almost never needs to care about timezones and daylight saving rules.

Information about the local time zone is stored in the global kconfig configuration area and initialized on the first call to any local time function.

Local/UTC time conversion is done using the public domain zoneinfo codebase.

## ERRORS

Raises an error if datetime is not a datetime instance.

## EXAMPLE

>
print (clock.currentDateTime():toLocal())
2009-08-06T13:11:48

## SEE ALSO

clock.currentDateTime, clock.newDateTime, clock.setDateTime, 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:year, datetime:zone, tostring(datetime)