I just ran into a quirk with displaying DateTime fields in visualforce. Apparently, the tag does not convert the date into the current user’s timezone but rather renders it in GMT (the value as salesforce stores it internally).
Tue May 27 02:50:00 GMT 2014
I did some googling and came across this request on the IdeaExchange as well as various workarounds from various blogs and forums, some were as complex as creating custom component and controller to do the timezone conversion in apex. Creating a custom component seems like too much trouble to me to just get a date to display correctly. Thankfully, the simplest solution was just to add whitespace to the front of the value expression and voila!
5/26/2014 9:50 PM
I don’t know why adding the whitespace makes the format display correctly, but it does, and until it doesn’t then no need for extra code to write/test/maintain.
But don’t forget, unless you actually need to use tag for custom message formatting, you can always use tag and it displays the date in the current user’s timezone correctly (no hack required!).
Chirag Mehta pointed out in the comments of this post that this workaround does not work when using using tag with nested element, such as when wanting to use a custom date format. As I originally mentioned, if you need to use custom message formatting then you’ll need to resort to a more complex apex solution (e.g. generate the appropriate display string in apex and display in visualforce).
5/27/2014 02:50 AM GMT