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

Adding date format to the VF page


     I have VF page where it displays the related cases upon selecting the case owner on top , the case owner drop down appears on left hand side of screen now i want to add the todays date on the right hand side? is it possible to add the date ?


This is what i have for case owner drop down now how to add date to the below?


<apex:pageBlockSection >
 <apex:inputField id="own" value="{!case.Case_Owner__c}"  onChange="getSelectedId('{!$Component.own}');"/>





Dates can be added like so:

Today's date and time is: {!NOW()} gives you Today's date and time is: Mon Jul 21 16:12:10 GMT 2008

Today's date is: {!TODAY()} gives you Today's date is Mon Jul 21 00:00:00 GMT 2008


More details here:


I have tried using {!TODAY()} but i guess i can't use it in input function since it's not a field so how do i use it?


<apex:pageBlockSection >
 <apex:inputField id="own" value="{!case.Case_Owner__c}"  onChange="getSelectedId('{!$Component.own}');"/>
 <apex:inputField value="{!TODAY()}"/>


Use inputText for inputs that aren't bound to SObject fields.




Use the below code snippets for reference


------ Vf page -------------

<apex:page controller="adddaysindate" >
function adddays(fieldval)
    var chkval=fieldval.value;


 <apex:form >
 <apex:actionFunction name="calladddays" reRender="pp" action="{!adddaysindate}"> <apex:param name="assignvalue" value="" assignTo="{!getdate}"/></apex:actionFunction>
 <apex:inputField value="{!con.Birthdate}" onchange="adddays(this)"/>
 <Apex:outputPanel id="pp" >

  <apex:outputText value="{!printdate}" ></apex:outputText>
 ---------Apex Controller ------------------
 public class adddaysindate
public contact con{get;set;}
public string getdate{get;set;}
public date chk{get;set;}
public string printdate{get;set;}
public adddaysindate()
    con=new contact();

public void adddaysindate()
    date t=date.parse(getdate);

 Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


Hi Sam,


I think you trying to display today's date on your visualforce page. So Try this out,


<apex:outputText value="{0,date,d MMM yyyy}">
<apex:param value="{!today()}" />



Change the date formate as you wish in "Value" and mark it as a solutions if it works.