DateTime2UTC
- Last UpdatedOct 29, 2026
- 2 minute read
This function converts a date and time from the specified time zone to Coordinated Universal Time (UTC).
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
DateTime2UTC |
Date and Time |
Synchronous |
Yes |
Supported |
Supported |
Not supported |
Supported |
Executed on Server |
Syntax
DateTime2UTC( strDateTime, optTimeZone )
DateTime2UTC ( strDateTime { | ,optTimeZone } )
strDateTime
The date and time to be converted. The date must be formatted according to the current date format; for more information, see About the date format and how to change it. The time must be formatted as HH:MM:SS.
optTimeZone
A time zone name (string) or index (integer).
|
Value |
Description |
|---|---|
|
-i |
A time zone index (i), up to the maximum index returned by the function GetTimeZoneCount. |
|
0 |
The current time zone in either the project runtime server or the project thin client, depending on where the function is called. This might be different from the current time zone in the local computer's system settings, if the function SetTimeZone was previously executed. |
|
1 |
Coordinated Universal Time (UTC). |
|
2 |
The current time zone in the local computer's system settings. |
|
"timezone" |
The full name of a time zone (for example, "Central Standard Time"). |
This parameter is optional; if no value is specified, the default value is 0.
Returned value
If this function is executed successfully, it returns a string that contains the specified date and time converted from the specified time zone to UTC. Otherwise, it returns one of the following possible values:
|
Value |
Description |
|---|---|
|
-5 |
Invalid time zone name or index. |
|
-4 |
Invalid or improperly formatted date/time. |
|
-3 |
The specified value is not a string. |
|
-2 |
Invalid number of parameters. |
Notes
The list of available time zones varies by operating system version and configuration. If necessary, you can use the functions GetTimeZoneCount and GetTimeZone to generate a list that is specific to your computer.
If this function is called in a project screen on Mobile Access, it is executed using the system clock and date/time settings on the computer that hosts the project runtime server.
Examples
Convert the specified date and time from the current time zone to UTC:
DateTime2UTC("07/15/2013 19:54:46")
Convert the specified date and time from Central Standard Time to UTC:
DateTime2UTC("07/15/2013 19:54:46","Central Standard Time")