1

I want to display only time value in apex:outputText.Is there any format to display only time.?

Thanks in advance.

1 Answer 1

4

You need to use a apex:param for that:

   <apex:outputText value="The formatted time right now is: 
         {0,date,HH:mm:ss}">
       <apex:param value="{!NOW()}" />
   </apex:outputText>

Check this doc: apex:outputText

6
  • thanks for the response.i tried that before i am getting "The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice" error. Commented Sep 9, 2014 at 6:56
  • The above code works if we use NOW() function,if i use DateTime field of Custom object its showing error. Commented Sep 9, 2014 at 7:00
  • @NullReferenceException Your comment is not correct. It work with a normal custom DateTime field very well, just checked in my dev org. Commented Sep 9, 2014 at 7:10
  • I am getting the error "The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice". This is my code <apex:column headerValue="Start Time"> <apex:outputText value="{0,date,HH:mm:ss}"> <apex:param value="{!item.StartTime__c}"/> </apex:outputText> </apex:column> Commented Sep 9, 2014 at 7:15
  • @NullReferenceException There is something wrong with your StartTime__c value. Better check it without using above solution firstly. And the field should be of type DateTime of cource, not a Text or something else. Commented Sep 9, 2014 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .