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
HelloSanHelloSan 

Javascript to capture current date and time in US format and saved into custom date and time field

karthikeyan perumalkarthikeyan perumal
Hello, 

This will print the date out in the format December 14, 2013. The documentation can be found here (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm

Javascript 
 
(function () {

    var date = new Date(),
        output = document.getElementById( 'output' ),
        dateString = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear().toString().substr(2,2);


    output.innerHTML = dateString;

})();
Fiddle: http://jsfiddle.net/ubR5m/​ (http://jsfiddle.net/ubR5m/)
<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>

or if all you need is the current date printed out in that format then you can use this:
 
<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!NOW()}" />
</apex:outputText>
OR
 
<apex:outputText value="string: {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}"> 
<apex:param value="{!acct.CreatedDate}" /> 
</apex:outputText>

JavaDocs for SimpleDateFormat (http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html)

 
Hope this will help you. 
Thanks
karthik