Converts local time to Coordinated Universal Time (UTC), or UTC to local time. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if necessary.
UTC- or local-formatted time object.
DateConvert(conversionType, date)
GetTimeZoneInfo, CreateDateTime, DatePart
Parameter |
Description |
|---|---|
conversionType |
|
date |
Date and time string or a variable that contains one. To create, use CreateDateTime. |
When passing a date/time object as a string, enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.
You can pass the CreateDate or Now function as the date parameter of this function. For example, cfscript> writeoutput(DateConvert('local2utc',CreateDate(2019, 4, 10))) </cfscript> |
<cfscript>
// convert local date-time to UTC
utc_datetime = DateConvert('local2Utc', now());
writeOutput(utc_datetime & "<br/>")
// convert UTC date-time to local
local_datetime=DateConvert('utc2Local',now())
writeOutput(local_datetime)
</cfscript>
Output
{ts '2018-11-08 06:41:19'}
{ts '2018-11-08 06:41:19'}
Sign in to your account