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
TapasviniTapasvini 

formatting date

I want to format the date and display it into vf page.my code is:

 

<script>
function DynamicDatePicker(d_id)
{
DatePicker.pickDate(false,d_id.id,false);
}
</script>

 

<apex:inputText id="FromDate" value="{!FromDate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="20" disabled="false" style="width:150px;"/>

 

title: {!FromDate}

 

class:

 public Date FromDate { get; set; }

 

I am getting the value is:Fri Sep 21 00:00:00 GMT 2012

but I want it like 09/21/2012.

 

I have tried format method but it doesnt work. So, can anyone give me the solution.

Thanks.

SabrentSabrent

I have used this in one of my pages and gives me the desired output -

 

 

<apex:page standardController="Contact">
  <apex:pageBlock title="Test">
   <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>  
  </apex:pageBlock>                   
  
</apex:page>
TapasviniTapasvini

But I want to display it in javascript. So in that I cant use the <apex:outputtext>.

SabrentSabrent

sorry didn't realize that.

 

You mentioned you tried format , did you try toString

 

something like,  tostring(MM'/'dd'/'yyyy)