soderlind / acf-field-date-time-picker

Date and Time Picker field for Advanced Custom Fields v3 and v4
GNU General Public License v2.0
65 stars 27 forks source link

Date and time breaks without minutes in format #45

Closed sirreal closed 10 years ago

sirreal commented 10 years ago

I was trying to use this plugin with a custom date format that did not include minutes. When saving posts, the post would appear to save correctly, but the date was never saved. It would be empty in the post page and the DB would have an empty field stored for the date.

The formats I was using were

'date_format' => 'DD dd MM yy'

and

'time_format' => 'HH'

I was working to debug and added a new field with default format and it saved correctly. I assume this is related to the plugin not understanding a date format without minutes.

Here is the relevant ACF export (you will want to change post_type from custom type event to test).

<?php
    register_field_group(array (
        'id' => 'acf_champs-evenement',
        'title' => 'Champs: Événement',
        'fields' => array (
            array (
                'key' => 'field_53591c3095e97',
                'label' => 'Date de début',
                'name' => 'date_start',
                'type' => 'date_time_picker',
                'required' => 1,
                'show_date' => 'true',
                'date_format' => 'DD dd MM yy',
                'time_format' => 'HH',
                'show_week_number' => 'false',
                'picker' => 'slider',
                'save_as_timestamp' => 'true',
                'get_as_timestamp' => 'false',
            ),
        ),
        'location' => array (
            array (
                array (
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'event',
                    'order_no' => 0,
                    'group_no' => 0,
                ),
            ),
        ),
        'options' => array (
            'position' => 'normal',
            'layout' => 'default',
            'hide_on_screen' => array (
            ),
        ),
        'menu_order' => 0,
    ));
sirreal commented 10 years ago

This issue makes some incorrect assumptions about the problems mentioned in issue #46.