Skip Navigation

[Resolved] convert gravity forms date to unix timestamp to save in toolset date field

This support ticket is created 5 years, 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1273025

Tell us what you are trying to do?
Convert the date entered into a gravity form into a unix timestamp before it is saved to my toolset custom date field.

Here is the code I wrote, that isn't working:

add_action( 'gform_after_submission_11', 'modify_birth_date', 10, 2 );
function modify_birth_date( $entry, $form ) {
$post_id = get_the_ID();
$birth_date = rgar( $entry, '2' );
$birth_timestamp = str_to_time($birth_date);
update_post_meta($post_id, 'wpcf-animal-birth-date', $birth_timestamp);
}

Is there any documentation that you are following?
All of the toolset support threads on this topic share the code under a hidden link (aargh).

Is there a similar example that we can see?

What is the link to your site?
Here's the form on our development site:
hidden link
It breaks when you submit it and is saving the Birth Date in the Gravity Forms format.

#1273097

Hello,

It is a custom codes problem, I suggest you debug the codes manually line by line.

According to gravity forms document:
hidden link
You can get the post ID directly, for example:

$post_id = $entry['post_id'];