+ Start a Discussion

Date formate

When i fetch date field value in my visualforce page it gives like this "Fri Sep 09 00:00:00 GMT 2011", i need to change the format as dd/mm/yyyy in my custom visualforce page.



pass the salesforce date value in to following java script function

write this function in your vf page java script tag


on event on select or on click call java script and pass the selected value to java script and set the value in  to the text box (document.getElementbyId.value=manupulated date)

function dateComparator(val){    


var selectedDate= new Date(val);

var newSelectedDate= selectedDate.getMonth()+1+'/'+selectedDate.getDate()+'/'+selectedDate.getFullYear(); 

// document.getElementbyId('TextBoxId').value=newSelectedDate;



It will help you or you need to user standard salesforce date object and using the API u can perform date operation at server side.







Rahul SharmaRahul Sharma

Use a param here to format your value if you are using outputText.

like this:

<apex:outputText value="{0,date,M/d/yyyy}">
    <apex:param value="{!object.dateField}" />

 hope it helps!