– Common Function Library Project

getIsoTimeString(datetime[, convertToUTC])

Last updated August 01, 2013


Ben Nadel

Version: 1 | Requires: CF9 | Library: DateLib

Takes your ColdFusion date/time object and returns a string that represents the date in ISO 8601 complaint format. This separates the date/time values with a "T" and ends with the UTC-marker, "Z". Since it uses the UTC-marker, it will convert your date/time into UTC, unless you tell it not to (using the optional argument).

Return Values:
A date string as per ISO format


currentTime = now();

// Compare the HTTP time to the ISO time.
writeOutput( "HTTP Time: " & getHttpTimeString( currentTime ) );
writeOutput( "<br />" );
writeOutput( "ISO Time: " & getIsoTimeString( currentTime ) );


Name Description Required
datetime A date/time object Yes
convertToUTC Whether to convert to UTC before formatting (default true) No

Full UDF Source:

 * Converts your date into a time string the aheres to the ISO 8601 standard (for use with some API calls).
 * v1.0 by Ben Nadel
 * @param datetime      A date/time object (Required)
 * @param convertToUTC      Whether to convert to UTC before formatting (default true) (Optional)
 * @return A date string as per ISO format 
 * @author Ben Nadel ( 
 * @version 1.0, August 1, 2013 
string function getIsoTimeString(required date datetime, boolean convertToUTC=true) {
    if (convertToUTC) {
        datetime = dateConvert("local2utc", datetime);

    // When formatting the time, make sure to use "HH" so that the
    // time is formatted using 24-hour time.
        dateFormat(datetime, "yyyy-mm-dd") &
        "T" &
        timeFormat(datetime, "HH:mm:ss") &


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson