Ok, so I did basically what Jeroen suggested.
You can get information about the current logged in user by using the mx.session.getUserAttribute() function, so I used it to get the association (GUID) to the TimeZone object for that user, then I used mx.data.get() to get the actual TimeZone object using that GUID.
After that, I got the RawOffset attribute of the TimeZone object. This is in milliseconds, and so is the value returned from MxObj.get() when used on a DateTime field. So, you can just use MxObj.get() to get the DateTime value and then add the RawOffset value to it directly, then in JavaScript, create a Date object with the resulting sum.
After that, it looks like the times coming from both sources are matching up.
Hi David,
Have a look at this datetime faq in the docs.
In brief:
Unfortunatly, I don't know a neat way to deal with this in the widget.
Perhaps you could retrieve the System.TimeZone for the current user and apply the offset to the date that you receive before formatting it, but that might also lead to some inconsistencies on the long run..
Hope it at least gives you a little more info.
I think you can use
dojo.date.locale.format
Ok, so coming back to this issue, I've noticed that the DateTime offset I'm getting in the widget is not being adjusted for Daylight Savings. Currently here in the Netherlands, we are in CEST, which is GMT + 2:00, but the offset I'm getting in the widget is still GMT + 1:00, which is our normal timezone. However, times shown in the browser through, for instance, a Date Picker widget, are being adjusted to GMT + 2:00 because the browser is reporting that I'm in CEST.
According to the DateTime FAQ that Jeroen mentioned, timezone should be adjusted automatically for daylight savings time, but that doesn't seem to be the case, or I'm doing something wrong. Anyone have any thoughts?