+ Start a Discussion
sam_Adminsam_Admin 

Adding date format to the VF page

Hello,

     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}');"/>
 </apex:pageBlockSection>

 

 

TIA!

doubleminusdoubleminus

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: 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_variables_functions.htm?SearchType=Stem

sam_Adminsam_Admin

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()}"/>
 </apex:pageBlockSection>

jwetzlerjwetzler

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

Navatar_DbSupNavatar_DbSup

Hi,

 

Use the below code snippets for reference

 


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

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

</script>

 <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:outputPanel>
 
 </apex:form> 
 </apex:page>
 
 ---------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);
    chk=t.adddays(10);
    printdate=chk.format();
}
}

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

Arish_KhanArish_Khan

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

 

 

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

 

 --

Thanks

Arish