You need to sign in to do that
Don't have an account?

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.
Hi,
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()
{
currntdate=string.valueof(system.now());
currenttime=string.valueof(system.now().format('hh:mm:ss'));
url=ApexPages.currentPage().getHeaders().get('Host');
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}"/>
</apex:form>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.