User Guide Cancel

GetTimeZoneInfo

 

Description

Gets local time zone information for the computer on which it is called, relative to Universal Time Coordinated (UTC). UTC is the mean solar time of the meridian of Greenwich, England, used as the basis for calculating standard time throughout the world.
ColdFusion stores date and time values as date-time objects: real numbers on a universal time line. It converts an object to a time zone when it formats an object; it converts a date/time value from a time zone to a real number when it parses a value.

Returns

Structure that contains these elements and keys:

  • utcTotalOffset: offset of local time, in seconds, from UTC
    • A plus sign indicates a time zone west of UTC (such as a zone in North America)
    • A minus sign indicates a time zone east of UTC (such as a zone in Germany)
  • utcHourOffset: offset, in hours of local time, from UTC
  • utcMinuteOffset: offset, in minutes, beyond the hours offset. For North America, this is 0. For countries that are not exactly on the hour offset, the number is from 0 through 60. For example, standard time in Adelaide, Australia is offset 9 hours and 30 minutes from UTC.
  • isDSTOn: True, if Daylight Savings Time (DST) is on in the host; False, otherwise.
  • DSTOffset: Number of hours of daylight savings offset. (0 if DST is not active). It is the amount of time added to or subtracted from the standard time to account for Daylight Saving Time (DST).
  • name: The full name of the timezone, for example, Eastern Standard Time.
  • nameDST: The full name of the timezone, where DST is active, for example, Eastern Daylight Time.
  • shortName: The abbreviated name of the timezone, for example, EST.
  • shortNameDST: The abbreviated name of the timezone, where DST is active, for example, EDT.

History

  • ColdFusion (2025 release): Accepts timezone and locale as optional parameters.

Category

Date and time functionsInternational functions

Function syntax

GetTimeZoneInfo()

See also

DateConvertCreateDateTimeDatePart

Parameters

Parameter Required Description
timezone No Specify a timezone to return info from (Uses system timezone if not provided). For example, "US/Eastern"
locale No The locale used to format the output (Uses system local if not provided) For example, "en_US".

Example

<cfscript>
curdatetime = now();
writeOutput("The local date and time are " & curdatetime & "<br/>");
info = GetTimeZoneInfo();
writeOutput("Total offset in seconds is " & info.utcTotalOffset & "<br/>");
writeOutput("Offset in hours is " & info.utcHourOffset & "<br/>");
writeOutput("Total offset in minutes minus is " & info.utcMinuteOffset & "<br/>");
writeOutput("Is DST? " & info.isDSTOn & "<br/>");
</cfscript>
<cfscript> curdatetime = now(); writeOutput("The local date and time are " & curdatetime & "<br/>"); info = GetTimeZoneInfo(); writeOutput("Total offset in seconds is " & info.utcTotalOffset & "<br/>"); writeOutput("Offset in hours is " & info.utcHourOffset & "<br/>"); writeOutput("Total offset in minutes minus is " & info.utcMinuteOffset & "<br/>"); writeOutput("Is DST? " & info.isDSTOn & "<br/>"); </cfscript>
<cfscript>
     curdatetime = now();
     writeOutput("The local date and time are " & curdatetime & "<br/>");
     info = GetTimeZoneInfo();
     writeOutput("Total offset in seconds is " & info.utcTotalOffset & "<br/>");
     writeOutput("Offset in hours is " & info.utcHourOffset & "<br/>");
     writeOutput("Total offset in minutes minus is " & info.utcMinuteOffset & "<br/>");
     writeOutput("Is DST? " & info.isDSTOn & "<br/>");
 </cfscript>

Output

The local date and time are {ts '2024-09-10 16:37:25'}
Total offset in seconds is 0
Offset in hours is 0
Total offset in minutes minus is 0
Is DST? NO

Example 1- only timezone

<cfscript>
writeDump(getTimeZoneInfo("Asia/Singapore"));
writeDump(getTimeZoneInfo("Japan"));
</cfscript>
<cfscript> writeDump(getTimeZoneInfo("Asia/Singapore")); writeDump(getTimeZoneInfo("Japan")); </cfscript>
<cfscript>
    writeDump(getTimeZoneInfo("Asia/Singapore"));
    writeDump(getTimeZoneInfo("Japan"));
</cfscript>

Example 2- timezone and locale

<cfscript>
writeDump(getTimeZoneInfo("Asia/Kolkata","zh_CN"));
writeDump(getTimeZoneInfo("Asia/Kolkata","ja_JP"));
</cfscript>
<cfscript> writeDump(getTimeZoneInfo("Asia/Kolkata","zh_CN")); writeDump(getTimeZoneInfo("Asia/Kolkata","ja_JP")); </cfscript>
<cfscript>
    writeDump(getTimeZoneInfo("Asia/Kolkata","zh_CN"));
    writeDump(getTimeZoneInfo("Asia/Kolkata","ja_JP"));
</cfscript>

In ColdFusion (2025 release), the function returns a struct with the following additional elements:

  • DSTOffset: Number of hours of daylight savings offset. (0 if DST is not active). It is the amount of time added to or subtracted from the standard time to account for Daylight Saving Time (DST).
  • name: The full name of the timezone, for example, Eastern Standard Time.
  • nameDST: The full name of the timezone, where DST is active, for example, Eastern Daylight Time.
  • shortName: The abbreviated name of the timezone, for example, EST.
  • shortNameDST: The abbreviated name of the timezone, where DST is active, for example, EDT.

Get help faster and easier

New user?