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

1,037 views

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.

Challenges in your career

🎯 If You Are Facing Any Of These 6 Challenges in your career.

  • Learn Salesforce Development
  • Career Confusion
  • No Interview Call
  • Low Salary
  • No Promotion/Growth
  • No Finding New Job Opportunity
  • Why you stucking from past so many years in same company?

 

  

 

Final Output →

displaying date in Visualforce page -- w3web.net

 

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 DATE.today(); }}
  3.     public currentDateVfCtrl(ApexPages.StandardController Controller){
  4.  
  5.     }
  6.  
  7. }

 

get current date in Visualforce page -- w3web.net
 

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

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration




Hi, This is Vijay Kumar behind the admin and founder of w3web.net. 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 w3web.net

Leave a Comment