+ Start a Discussion
Ayyagari RameshAyyagari Ramesh 

how to print present date in date field which should reflect automatic when vf page opens

Best Answer chosen by Ayyagari Ramesh
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ayyagari,

Greetings to you!

Please try the below sample code, it is working fine. Kindly modify the code as per your requirement.

Visualforce:
<apex:page controller="DateInVfC">
    <apex:form>
		<apex:inputField value="{!st.Date_Field__c}"/>
    </apex:form>
</apex:page>

Controller:
public class DateInVfC {

    public Khan__c st {get;set;}
    
    public DateInVfC(){
        st = new Khan__c();
        st.Date_Field__c = System.today();
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas