Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

How do I print the current date on Visualforce?

Stuff like Today(), System.now, doesn't work.

Haven't been able to find any documentation or stackoverflow questions regarding this subject.

1 Answer

0 votes
by (32.1k points)

You need to create a property in your controller like:

public Date Today { get { return Date.today(); }}

When you're using the VF page, use the following piece of code:

<apex:outputText value="{0,date}">

    <apex:param value="{!Today}" />

</apex:outputText>

Related questions

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...