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 →
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]
|
<apex:page standardController="Quote" extensions="currentDateVfCtrl">
<p style="margin:0; padding:10px 0 0 35px; font-size:22px;">
<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>
</p>
</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]
|
public class currentDateVfCtrl {
public DATE todayStr { GET { RETURN DATE.today(); }}
public currentDateVfCtrl(ApexPages.StandardController Controller){
}
}
Further post that would you like to learn in Salesforce
You can download file directly from github by Click Here.
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 |