I need Date picker field in visualforce page.
When select that field the date format should like YYYY-MM-DD
How to achieve this?
Thanks for all your response..
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI need Date picker field in visualforce page.
When select that field the date format should like YYYY-MM-DD
How to achieve this?
Thanks for all your response..
You can bind directly to a date field on an sObject(in my example contact) using Visualforce like this:
<apex:inputField value="{!Contact.BirthDate}" />
Visualforce will render as appropriate based on the data type of your field. So if your using standard Salesforce styles in your page, this will cause the salesforce default calendar to be displayed. Otherwise you can take a look here for some more ideas. Also it may be worthwhile to take a look at this for info on how you can format dates in VF.
Native salesforce picker format is MMDDYYYY
. To change it into YYYYMMDD
, use below JavaScript code example:
var EffDate=document.getElementById("effdate").value;
if (EffDate) {
EffDate = EffDate.replace(/(\d{4})-(\d{1,2})-(\d{1,2})/, function(match,y,m,d) {
return m + '/' + d + '/' + y;
});
}