Skip to content

Instantly share code, notes, and snippets.

@norcross
Created April 1, 2012 17:20
Show Gist options
  • Save norcross/2277175 to your computer and use it in GitHub Desktop.
Save norcross/2277175 to your computer and use it in GitHub Desktop.
Convert date entry to UNIX timestamp
// Make two admin-only fields (as text fields)
// and post to the custom fields from Gravity Forms
// instead of the "real" date picker.
// NOTE: change the input IDs to match the ones on your form
function rkv_datesubmit_fix ($form){
//event start date field id is 3
//event end date field ID is 4
$raw_srt = $_POST['input_3'];
$raw_end = $_POST['input_4'];
// convert my dates
$fix_srt = strtotime($raw_srt);
$fix_end = strtotime($raw_end);
//admin start date field ID is 35
//admin end date field ID is 36
$_POST['input_35'] = $fix_srt;
$_POST['input_36'] = $fix_end;
}
add_action('gform_pre_submission', 'rkv_datesubmit_fix');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment