Setting a Form Field to the Current Date and Time

With these instructions, you can populate a hidden form field with the current date and time.

Note: if you want a user-selectable date field, see this solution for using a calendar date picker in your form: Adding a Date Picker to a Form


Is this article helpful ?

YesNo


First, you need to add a hidden field to your form.  See these instructions if you don't know how: Making a Field Hidden on a Form

 

Next, add the following Javascript to your landing page in a Custom HTML element. You'll need to update the field ID, highlighted in yellow, to match the ID of the hidden field you want to populate. These directions show you how to find that ID: Setting or getting a form field value via Javascript on a landing page

 

Note: Please ensure that you have access to an experienced JavaScript developer.

Marketo Technical Support is not set up to assist with troubleshooting JavaScript.