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

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

  • 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 Dec 17 '13 at 9:47
  • Have you used docType="html-5.0"? – Sergej Utko Dec 17 '13 at 10:00
  • Yes, It is @mast0r – highfive Dec 17 '13 at 10:06
  • 1
    Seems HTML5 <input /> is not much have the browser compatibility check here – highfive Dec 27 '13 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.