Skip Navigation

[Gelöst] Which Date Format to update Date Field

This support ticket is created vor 7 Jahre, 11 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 Antworten, has 2 Stimmen.

Last updated by mirjanaM vor 7 Jahre, 11 Monate.

Assisted by: Luo Yang.

Author
Artikel
#394354

Hi,

i have made a post form with Formidable which have a Date field and is not compatible to Custom Fields made with Types. But i have to update my Types Field and have much Problems here so i hope anyone can help.

What i have figured out is that Toolset Types saves the date in Unix format. So with help from the formidable devlopers i have this code now. This will adjust the date format before that custom field (from formidable) is saved.
But the Problem here is furthermore not working and i get wrong values like 01/04/1970 in Types Field.

add_filter( 'frm_new_post', 'create_a_custom_field', 10, 2 );

function create_a_custom_field( $post, $args ) {

  $field_id = 102; // change 25 to the id of the field to draw from

  if ( isset( $_POST['item_meta'][ $field_id ] ) ) {

    $field_value = sanitize_text_field( $_POST['item_meta'][ $field_id ] );

    $post['post_custom']['wpcf-startzeit-produkttests'] = gmdate( 'timestamp', $field_value ); // uncomment to save a different date format and change 'custom_field_name_here'

  }

  return $post;

}

Please Help

#394485

Dear mirjana,

According to our Customer Support Policy, we do not provide custom codes support:
https://toolset.com/toolset-support-policy/

I am not familiar with the Formidable plugin, I assume the Formidable plugin is passing the POST parameter for date field, like this:
2009-02-15 (Y-m-d)

You can try to modify your PHP codes, for example, replace this line, from:

...
$post['post_custom']['wpcf-startzeit-produkttests'] = gmdate( 'timestamp', $field_value );
...

To:

...
$date = DateTime::createFromFormat('Y-m-d', $field_value);
$post['post_custom']['wpcf-startzeit-produkttests'] = $date->getTimestamp();
...

More help:
hidden link

#394511

Hi Yang,

sorry this is also not working (try´d just now). I think you misunderstood this, this code should adjust the date format before that custom field (from formidable) is saved.
So what i need is the right date format for wp-types custom field, so the date will be accepted from wp-types custom field wenn form is saved.

#394517

Hi Yang,

sorry its working.

I make something wrong. Sure you where right with this 🙂

Thank You

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.