Description

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.

Returns

UTC- or local-formatted time object.

Category

Date and time functions

Function syntax

DateConvert(conversionType, date)

See also

GetTimeZoneInfoCreateDateTimeDatePart

Parameters

Parameter

Description

conversionType

  • local2Utc: Converts local time to UTC time.
  • utc2Local: Converts UTC time to local time.

date

Date and time string or a variable that contains one. To create, use CreateDateTime.

Usage

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: #DateConvert(CreateDate(2007, 4, 10))#

Example

<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'}

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy