Skip to main content
All CollectionsFAQs
How do I capture time and date into two fields from my landing page?
How do I capture time and date into two fields from my landing page?

If you need the time and date of the capture to be added to your leads coming in via a landing page, then this guide will walk you though it

James Dodd avatar
Written by James Dodd
Updated over 3 years ago

Add the fields to your campaign

First, in your campaign, create 2 new fields

time_submitted

date_submitted

Field Types

We need these fields to be set as hidden hields.

Head to your field definittions: Leads > Fields

Find your field here and then head to the Form Field area and ensure the type is set to hidden.

Add to landing page

Next we need to add these fields to our landing page. So head to the page and edit your form. Turn the fields on.

Next step is to synchronise HTML to insert the relevant fields into your form (this will insert fields between each fieldset tag).

Add some custom JavaScript

The final step, is to add the following script to you JavaScript tab of the file (or site assets or site-layout).

$("[type='submit']").click(function () {var time = (new Date).getHours() + ":" + (new Date).getMinutes() + ":" + (new Date).getSeconds(); var day = (new Date).getDay();//where F_Number_fieldName change to apply to your field-yield data-field name//e.g., <field-yield data-field="F_1120_TIME_SUBMITTED"></field-yield>$('input[name="F_1120_TIME_SUBMITTED"]').val(time).trigger('change');$('input[name="F_1121_DATE_SUBMITTED"]').val(day).trigger('change');});

You'll need to replace the following field references, with ones that match the fields you created F_1120_TIME_SUBMITTED & F_1121_DATE_SUBMITTED

Result:

Time being passed as HH:MM:SS (Hours, minutes, seconds).
Current Day being passed numerically (1 for Monday, etc).

You could create an array for days of the week and populate the value of the actual day based on the array number. If the value was 1 the value could be Monday for example.

mceclip5.png
Did this answer your question?