DatePicker UTC

257 views
Skip to first unread message

Thomas Lefort

unread,
Mar 28, 2012, 4:07:39 PM3/28/12
to google-we...@googlegroups.com
I need the datepicker to render the date in UTC and not the local
format. Is there any simple way to do so?

Thomas Lefort

unread,
Mar 29, 2012, 9:03:48 AM3/29/12
to google-we...@googlegroups.com
To be more clear, I have a date which is 2012-03-29 at 01:00:00 UTC, if I do setDate(date) on the datepicker and if the user is based in the US, the date selected on the calendar will be the 2012-03-28, because it uses their local time. I want the calendar to show 2012-03-29 wherever the user is.

Kevin Jordan

unread,
Mar 29, 2012, 9:56:33 AM3/29/12
to google-we...@googlegroups.com
http://code.google.com/p/gwt-traction/ (Look for UTCDateBox towards the bottom)

I created one based off of this for GXT and this should do what you want.  Although when I went to create a GXT version, I kept it so get/setValue used Date and not Long but did the timezone offset subtraction that this did.

Thomas Lefort

unread,
Apr 15, 2012, 5:44:41 AM4/15/12
to google-we...@googlegroups.com
Just saw your answer, thanks.

I use JsDate to get the UTC conversion. However this still doesn't work for the picker, as it will still display the date using the local time format. If I have 12/04/2012 at 1am UTC in the US, it will show me the picker at 11/04/2012. May be the solution would be to pass a "converted" date to the picker, ie add the time offset to the data when opening the picker. I do not use the DateBox but my own widget, so I can pass the date I want to the picker.
Reply all
Reply to author
Forward
0 new messages