How to display Current Date and Year field using apex:outputText in Visualforce page || How to get Date Format the Current Date and Year in Visualforce Page Salesforce || Displaying Date in mm/dd/yyyy format in Visualforce page


Hey guys, today in this post we are going to learn about How to get Date Format the Current Date and Year in Visualforce Page Salesforce.

Using Date, Date/Time, and Time Values in Formulas:-

Two data types are used for working with dates: Date and Date/Time.  One data type, Time, is independent of the date for tracking time such as business hours. Most values that are used when working with dates are of the Date data type, which store the year, month, and day. Some fields, such as CreatedDate, are Date/Time fields, meaning they not only store a date value, but also a time value (stored in GMT but displayed in the users’ time zone). Date, Date/Time, and Time fields are formatted in the user’s locale when viewed in reports and record detail pages. A Time value’s precision is in milliseconds. A Date/Time value’s precision is in seconds. To know more details, Click Here.



Final Output →

displaying date in Visualforce page --


You can download file directly from github by Click Here.


Other related post that would you like to learn in Salesforce


  • Find the below steps ▾


Create Visualforce Page

Step 1:- Create Visualforce Page : currentDateVf.vfp

From Developer Console >> File >> New >> Visualforce Page

currentDateVf.vfp [Visualforce Page]

  1.    <apex:page standardController="Quote"  extensions="currentDateVfCtrl">
  2.     <p style="margin:0; padding:10px 0 0 35px; font-size:22px;">
  3.         <span style="margin-right:5px; display:inline-block; color:#ff0000; font-weight:bold;">Date:</span> <apex:outputText value=" {0,date}"> <apex:param value="{!todayStr}" /></apex:outputText>
  4.     </p>
  5. </apex:page>


Create Apex Class Extension Controller in Visualforce

Step 2:- Create Apex Class : currentDateVfCtrl.apxc

From Developer Console >> File >> New >> Apex Class

currentDateVfCtrl.apxc [Apex Class Controller]

  1.   public class currentDateVfCtrl {
  2.     public DATE todayStr { GET { RETURN; }}
  3.     public currentDateVfCtrl(ApexPages.StandardController Controller){
  5.     }
  7. }


get current date in Visualforce page --

Further post that would you like to learn in Salesforce


You can download file directly from github by Click Here.



FAQ (Frequently Asked Questions)

How do I get today's date in Salesforce?

To find the current moment as a Date/Time value, use NOW(). These functions are useful for finding dates in the future or past, or how many days away from today another date is. To take just the day, month, or year from a Date value as a number, use DAY(), MONTH(), or YEAR(), respectively.

How do I see the output of a VF page in Salesforce?

From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages and click the name of a Visualforce page to view its details, including when it was created, when it was last modified, and the Visualforce markup associated with the page.

What is today () in Salesforce?

For example TODAY()-LastActivityDate calculates the number of days since the last activity date. In this example, the formula field data type is a number.

Related Topics | You May Also Like

  • Our Free Courses →
  • 👉 Get Free Course →

    📌 Salesforce Administrators

    📌 Salesforce Lightning Flow Builder

    📌 Salesforce Record Trigger Flow Builder


Hi, This is Vijay Kumar behind the admin and founder of I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on

Leave a Comment