Whatever message this page gives is out now! Go check it out!

DateConvert

Last update:
May 18, 2026

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

Function syntax

DateConvert(conversionType, date)

See also

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,
cfscript>
writeoutput(DateConvert('local2utc',CreateDate(2019, 4, 10)))
</cfscript>

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

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page