Skip Navigation

[Resolved] Get date ID for UNIX conversion

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1338809

Bob

I'm making use of Formidable Forms to acquire user data. The entered date should be converted to UNIX time to populate the Toolset date field. I found this guide on their site: hidden link

Please tell me, where do I find the Toolset date field ID?

The code of the Formidable post:

add_filter('frm_validate_field_entry', 'set_my_expiration_date', 10, 3);
function set_my_expiration_date($errors, $posted_field, $posted_value){
if ( $posted_field->id == 25 ) { //change 25 to the ID of the date field to change

// Get the first date in a UNIX timestamp
$first_date = date_create_from_format( 'd/m/Y', $_POST['item_meta'][20] ); //Change 20 to the ID of the first date field and change d/m/Y to the format on your Formidable -> Global settings page
$first_date = date_format( $first_date, 'Y-m-d' );
$first_date = strtotime( $first_date );

// Get the final date in Y-m-d format
$final_date = strtotime('+7 day', $first_date);
$final_date = date('Y-m-d', $final_date);

// Save the final date as the posted value
$_POST['item_meta'][$posted_field->id] = $final_date;

}
return $errors;
}

#1338897

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Bob

For your use case I suspect you may be better off using the frm_after_create_entry hook, which seems similar to our cred_save_data hook.

hidden link

So once the post is created, you can get the post meta (which will be in whatever format the form is submitting it in) then convert it to a timestamp, and then update the post meta with that value.