function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Date And Time

Hi ,

How would i get the curent date and Time and the browser,

I need to display these on the vf page these have to come from

the controller,

Could anyone help me with the sample code, how to achieve this in salesforce


Thank you.


Try the below code as reference:
///////////////////////// Controller ////////////////////////////


public class currentdatetime
public string currntdate{get;set;}
public string currenttime{get;set;}
public string url{get;set;}
public currentdatetime()

system.debug('@@@@@@@@@@@Currentdate=========' +currntdate);
system.debug('@@@@@@@@@@@URL=========' +url);
/////////////////////////// VF Page ///////////////////////////////////
<apex:page controller="currentdatetime">
<apex:form >
CurrentDate:<apex:inputText value="{!currntdate}"/><br/>
CurrentTime:<apex:inputText value="{!currenttime}"/><br/>
BrowerUrl:<apex:inputText value="{!url}"/>


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