function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

controlling output style of dates in VF

We are building a sitemap VF page for our SF Knowledge integration, and I'm trying to force the output of the date to be in a unix-style timestamp.


what I want



what i get

Wed Aug 18 18:52:36 GMT 2010


how can i force the system to output a date the way it's actually stored?


Hi ,


   I am afraid we dont have any datetime formatting functions in visualforce rather try the following formatting example in Apex.


Datetime dt =;
System.debug(dt.format('yyyy-MM-dd\'T\'HH:mm:ss Z'));



  I tried it in execute Anonymous and it resulted out in



2010-09-08T16:37:58 +0530


Hope this helps. The result output will be in String so you can use outputText vf tag.



Customize format string and try to get answer from following sample



<apex:outputText value="{0, date,yyyy'-'MM'-'dd':T'hh':'mm':'ss}">
  <apex:param value="{!NOW()}"/>





Beware: apex:outputText value=... doesn't  seem to have a way to change the time zone.  If you are not in the GMT time zone this the technique was not useful.