Hi,
Is there a way to convert the date field value to the timestamp format when submitting the form?
Thanks for your help!
Cedric
Hi,
Is there a way to convert the date field value to the timestamp format when submitting the form?
Thanks for your help!
Cedric
No, but you could have a hidden text field, and using some PHP, you could fill in that field after submit by converting the date into a timestamp. Let me know if you want to work towards figuring this out. I can point you at a hook that might help you (grab the data).
Using a hidden text field is a great idea (why didn't I think of that?) !
But I will need help for the hook in order to grab the data !
I assume that I have to use hooks like gform_pre_submission or gform_pre_submission_filter ?
Ok,
I tried something but it doesn't work.
add_filter("gform_pre_submission_1", "convert_to_timestamp");
function convert_to_timestamp($form){
$_POST['input_2'] = strtotime( $_POST['input_2'] );
}
The value is not returned and nothing is written to the database. But when I try with the following code :
add_filter("gform_pre_submission_1", "convert_to_timestamp");
function convert_to_timestamp($form){
$_POST['input_2'] = '2012/11/15';
}
The value '2012/11/15' is written to the database. Weird.
Weird or not. GF must bypass the value if it is not a date format like 2012/11/13, right?
I will try to achieve my goals using a hidden field. And I will let you know.
You'll want to put the value into another field. You can't send the timestamp through the date field. You'll want to have a hidden text field to carry the timestamp into the database. You are close though.
Damned, you're fast! I was editing my post when you replied.
Thanks for your help. I will let you know as soon as I will be victorious! :)
Yeehaa, it was easy as f*** using hidden fields! Thanks for your help David!
No problem, glad you got it sorted. I love shoving data into hidden fields. :)