Skip Navigation

[Resolved] Date field problem

This thread is resolved. Here is a description of the problem and solution.

Problem:
Date field not working

Solution:
Toolset stores custom date field value as unix timestamp. You should convert the date string to unix timestamp and save it to database.

Relevant Documentation:
http://php.net/manual/en/function.strtotime.php

This support ticket is created 6 years, 9 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by matsF 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#625596

Hi,
We’re manually updating a couple of wp_post_meta fields using
```
if ( ! add_post_meta( $post_id, $meta_key, $meta_value, true ) ) {
update_post_meta ( $post_id, $meta_key, $meta_value );
}
```
. They are dates (YYYY-MM-DD), which are saved as this in the DB. I’ve checked the DB, and it looks correct.
However, in the admin panel, they show up like this:
1970-01-01. The field in Toolset Type is set to support the format which is being saved in the DB.
Do we need to update the field in some other way?

#625622

Nigel
Supporter

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

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

Hi there

Are you talking about Types date fields?

These are stored in the database as unix timestamps, not as recognisable date strings.

If you want to manually update the post meta for a Types date field you should first convert it to a timestamp before inserting into the database.

See hidden link

#625624

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Toolset stores custom date field value as unix timestamp. You should convert the date string to unix timestamp and save it to database.

Following link may help you:
=> https://stackoverflow.com/a/6501035

#625642

Seems to be working. Many thanks!