Support

Account

Home Forums Front-end Issues ACF date picker

Solving

ACF date picker

  • Hi there.
    I did run in some kind of a pickle.

    ACF
    wordpress 5.3.2
    php 7.0 / 7.1 / 7.2 / 7.3

    I’m using a field ‘pst_date’ od type date (with date picker).
    On blog edit, I set the value as ‘03.05.2020’. (Format: ‘d.m.Y’ for in- and output)
    I know date is saved as ‘Ymd’ in DB and formated on output acordingly.
    In the template using:

    <?php echo get_field('pst_date'); ?>

    output shows ‘02.05.2015’.

    I proofed the DB entry: ‘20200503’ is set correctly.
    I pretend not to care about the format, so I set output format to ‘Ymd’

    output shows ‘20150502’.

    So I fiddled around with other values and got the last Sunday of March as the culprit.
    before the ‘29.03.2020’ the output is correct after that output is one day short.
    Of course I tested it with different years same output.
    DST problems with get_field of format date? WTH? Whats up with that?

    Using code snippets from documetary:
    Input: ‘03.05.2020’ input-format ‘d.m.Y’ output-format ‘Ymd’

    $date_str = get_field('pst_date', $event);  // '20200502'
    $date = DateTime::createFromFormat('Ymd', $date_str);
    
    $mnth = $date->format('m');                     // 05
    $month = $date->format('M');                    // May
    $month = date_i18n('M', $date->getTimestamp()); // Mai
    $day = date('d', $date->getTimestamp());        // 02
    $day = date_i18n('d', $date->getTimestamp());   // 01  now we are even 2 days short???

    How can I fix this with using date picker?
    Will I have to switch ‘pst_date’ format to ‘String’?

    I can’t be the only one with that pickle!!!
    Wordpress time zone set to Berlin/Germany
    DST switch 29. März 2020 0:00
    Here we have an indicator, but why is there a date conversion?
    On March 29. the clock is turned forward at 2am to 3am so why are we loosing a day?

    How can I get get_field to use stored values at is?
    And how can I get php date functions to behave apropriately?
    ‘Google was no help!’

    Or do we have to fix conversion of date in date_picker?
    not to use Ymd 00:00:00 but add 2 or 3 hours (Ymd 02:00:00)
    for the output foramating process?

    Thank you very much.

  • Hi there.
    I did run in some kind of a pickle.

    ACF
    wordpress 5.3.2
    php 7.0 / 7.1 / 7.2 / 7.3

    I’m using a field ‘pst_date’ od type date (with date picker).
    On blog edit, I set the value as ‘03.05.2020’. (Format: ‘d.m.Y’ for in- and output)
    I know date is saved as ‘Ymd’ in DB and formated on output acordingly.
    In the template using:

    <?php echo get_field('pst_date'); ?>

    output shows ‘02.05.2015’.

    I proofed the DB entry: ‘20200503’ is set correctly.
    I pretend not to care about the format, so I set output format to ‘Ymd’

    output shows ‘20150502’.

    So I fiddled around with other values and got the last Sunday of March as the culprit.
    before the ‘29.03.2020’ the output is correct after that output is one day short.
    Of course I tested it with different years same output.
    DST problems with get_field of format date? WTH? Whats up with that?

    Using code snippets from documetary:
    Input: ‘03.05.2020’ input-format ‘d.m.Y’ output-format ‘Ymd’

    $date_str = get_field('pst_date', $event);  // '20200502'
    $date = DateTime::createFromFormat('Ymd', $date_str);
    
    $mnth = $date->format('m');                     // 05
    $month = $date->format('M');                    // May
    $month = date_i18n('M', $date->getTimestamp()); // Mai
    $day = date('d', $date->getTimestamp());        // 02
    $day = date_i18n('d', $date->getTimestamp());   // 01  now we are even 2 days short???

    How can I fix this with using date picker?
    Will I have to switch ‘pst_date’ format to ‘String’?

    I can’t be the only one with that pickle!!!
    Wordpress time zone set to Berlin/Germany
    DST switch 29. März 2020 0:00
    Here we have an indicator, but why is there a date conversion?
    On March 29. the clock is turned forward at 2am to 3am so why are we loosing a day?

    How can I get get_field to use stored values at is?
    And how can I get php date functions to behave apropriately?
    ‘Google was no help!’

    Or do we have to fix conversion of date in date_picker?
    not to use Ymd 00:00:00 but add 2 or 3 hours (Ymd 02:00:00)
    for the output foramating process?

    Thank you very much.

  • same problem here. any news?

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

The topic ‘ACF date picker’ is closed to new replies.