Getting Time Zone Info

We are trying to get all the Java Time Zone info. We used the following
and got the entire list:

<cfset variables.tzObj=createObject(“java”,“java.util.TimeZone”)>

  1. I’m wondering if someone can help me sort it by offset. I want tit to
    look more like the one within the Lucee Server Admin / Regional / Time Zone
    dropdown. 2. I was also wondering if anyone knows of a way that I can
    pass a TZ to a function and get the TZ abbreviation. EXAMPLE: Pass
    US/Central —>> CST

Any ideas?

Thanks in advance!

Here is the list with offsets added. I have also marked certain rows with display yes/no, which you can use to generate a generic list of world time zones:

Be aware that some timezones are subject to daylight savings and other are not, so the offsets may or may not change during the year.

You can check whether a timezone is subject to DST via:

tz = createObject( "java", "java.util.TimeZone" ).getDefault();
tz.setId( timezone );
observes = tz.observesDaylightTime();

Here is the code to generate the select list of generic time zones. Again, DST is not accounted for in this list, although you could add it using the Java TimeZone object.

<cfquery name=“get” datasource=“tz">
select timezone, displayname, offset, display
from timezone
group by offset, display, displayname, timezone
order by offset asc


<cfoutput>
	<cfscript>
		name = replacenocase( displayname, " STANDARD TIME", "" );
		name = trim(replacenocase( name, " TIME", "" ) );
		if( not listfind( label, name ) ){
			label = listappend( label, name );
		}
	</cfscript>

	<cfif display eq 1>
	&lt;option value='#timezone#'&gt; ( UTC #offset# ) #name#<br>
	</cfif>
</cfoutput>

> On Nov 8, 2016, at 11:25 AM, W. Williams <@W_Williams> wrote:

We are trying to get all the Java Time Zone info. We used the following and got the entire list:

<cfset variables.tzObj=createObject(“java”,“java.util.TimeZone”)>

  1. I’m wondering if someone can help me sort it by offset. I want tit to look more like the one within the Lucee Server Admin / Regional / Time Zone dropdown. 2. I was also wondering if anyone knows of a way that I can pass a TZ to a function and get the TZ abbreviation. EXAMPLE: Pass US/Central —>> CST

Any ideas?

Thanks in advance!


Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit CFCamp 2016 https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/ba1f84f6-7384-4ec6-91b4-94503a38b125%40googlegroups.com https://groups.google.com/d/msgid/lucee/ba1f84f6-7384-4ec6-91b4-94503a38b125%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

tz.csv (27.6 KB)