8

Does anyone know whether there is a standard Time picker or datetime picker available in Visualforce framework? Visualforce Date picker is a powerful component that can be easily used with . But when we are having DataTime field, there is no way to prompt the user to edit such a field value with a standard component. Isn't this still available?

Thanks,
Madhura

2 Answers 2

9

You can use a new & cool apex:input field that supports many types like time (learn more). Note that the visualforce page need to have a HTML5 doc type for that.

enter image description here

Here is an simple example:

Apex:

public Date myDate { get; set; }

Visualforce:

<apex:page controller="YourController" docType="html-5.0">
    <apex:form>
        Enter Time: 
        <apex:input type="time" value="{!myTime}"/>
    </apex:form>
</apex:page>

The result looks like this in Firefox 25:

enter image description here

4
  • Thanks @mast0r . I used this and it's working in chrome(31.0) but not in FF. Tried updating into v26 also but still not working. Additionally, for a DateTime field it's not allowing me to us the type as 'time'. Instead it's asking for 'datetime-local'. Any idea?
    – highfive
    Commented Dec 17, 2013 at 9:47
  • Have you used docType="html-5.0"? Commented Dec 17, 2013 at 10:00
  • Yes, It is @mast0r
    – highfive
    Commented Dec 17, 2013 at 10:06
  • 1
    Seems HTML5 <input /> is not much have the browser compatibility check here
    – highfive
    Commented Dec 27, 2013 at 7:59
2

After all I used a third party datetime picker as the solution since no where it's mentioned clearly about a visualforce datetime picker. I managed the datetime picker text with a string in the controller and used DateTime.valueof(string) to update my datetime field

You must log in to answer this question.

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