function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KaranrajKaranraj 

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.

navneetnavneet

 

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.

 

Regards,

 

Navneet

 

 

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}" />
</apex:outputText>

 hope it helps!