Convert date/time to GMT

617 views
Skip to first unread message

Jim Crone

unread,
Jul 2, 2013, 5:29:30 PM7/2/13
to dot...@googlegroups.com
I need to present some date/time information in GMT.  We are in the central time zone.  I was thinking about just adding the correct number of hours to the date to get GMT, but was then reminded about daylight savings time.  How can I consistently convert to GMT no matter what time of year it is?

Thanks,
Jim

Maria Ahues Bouza

unread,
Jul 3, 2013, 12:07:07 AM7/3/13
to dot...@googlegroups.com
Jim,

You can use Velocity's date tool to format the date using the GMT Timezone.

Try calling the date tool method to get the timezone and then setting the id.

Something like this

#set($myTimezone = $date.getTimeZone())
#set($dummy = $myTimezone.setID("GMT"))

Then call $date.format with the timezone. 


-Maria




--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Community Manager

dotCMS
Main: 305.900.2001
Fax: 305.397.2579
www.dotcms.com
http://www.twitter.com/dotCMS
http://www.facebook.com/dotCMS
http://www.twitter.com/mabouza

Please consider the planet before printing this email.

peter...@gmail.com

unread,
Aug 18, 2015, 8:15:28 AM8/18/15
to dotCMS User Group
Maria's aswer works, the only issue is, that you cannot change daylight settings. So it proved to me as better way to use:

#set($myTimezone = $date.getTimeZone().getTimeZone("UTC"))
Reply all
Reply to author
Forward
0 new messages