Home Forums General Issues Date Time Field Not Storing Value


Date Time Field Not Storing Value

  • I recently upgraded to newest free version of ACF 5.7.6 and am trying to use the new Date Time field, which is not storing any values. I previously had the free add on date time field plugin installed which I removed prior to getting the newest version of ACF. I believe these two are related and wanted to find out if anyone else has had this issue?

  • I have a similar issue. The prior free version 4.4.12 stored the Date Time value as a timestamp by default. I’ve found that the free 5.7.6 version stores the Date Time value as YYYY-MM-DD HH:MM:SS, with no option to store it as a timestamp. The database update that went along with 5.7.6 did not change the old Date Time values to the new format. After a couple of days of use, we discovered that the part of our website that depends on Date Time was broken because the database had mixed format values. I was forced to revert to a site backup done before the plugin update, losing a couple of days of work.

    I posted a support ticket to ACF but have not received a response. I’m sure they’re overloaded with support issues this week.


  • Both the old add on (it was not part of ACF and created by another developer) and the date field in ACF4 are different than the date field in ACF 5. Data is stored differently in the DB for both of them.

    In the case of the add on, if it is up to date and works with ACF5 you can probably still use it.

    As for the difference between ACF4 & 5, you will need to rework the front end to work with the way that ACF is now storing date fields.

  • Thanks, John. The writeup for the Date and Time Picker Field add-on says “ACF PRO 5.0+ is no longer supported, ACF PRO has its own date and time picker” so it looks like I’m up a creek because we have more than 2,000 existing posts in the add-on format.

  • @bocacommunity

    Yes, you have a problem.

    1 is that the other field is not supported and 2 is that if you add a field in ACF it will not have the same field key.

    You can create a temporary function that runs and replaces the data, the problem is that it might time out. I might do something like this (back up your database first)

    add_action('init', 'temp_replace_data_function') {
      if (!is_admin()) {
        // only run in the admin
      $args = array(
        // just a sample
        // do query to get all posts that have the old field
        'post_type' => 'post type to update',
        'posts_per_page' => -1,
        'meta_query' => array(
            // only get posts that have a value for this field
            // this way we can eliminate the ones we've already done
            // if it times out, re-running will not redo posts we've already taken care of
            'key' => 'old-field-name',
            'compare' => 'EXISTS'
        // other arguments as needed
      $query = new WP_Query($args);
      if ($query->have_posts()) {
        global $post;
        while ($query->have_posts()) {
          $post_id = $post->ID;
          // get the old value
          // convert it from what the other plugin is storing to ACF format
          // update the new ACF field (use the field key, not field name)
          // sorry I can't be much more help here
          // **** IMPORTANT ****
          // delete the post meta for the old field name
          // see not in the meta query above
          delete_post_meta($post_id, 'old-field-name');
  • Thank you so much, John. I think I’ll mirror the site and try this. The posts are too important – a school calendar in daily use.


  • This suggestion just came from ACF Support:

    I would suggest that you use the “acf/update_value/type=date_time_picker” filter to hook in and change the value being saved to a timestamp using the strtotime() function. Please take a look at the following resource page for more info on this:

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.