Support

Account

Home Forums General Issues date_picker – 1970

Helping

date_picker – 1970

  • Hello

    I used data picker for my website but It shows January 1 1970, Could you please help me what to do.

    the code which I used is:
    <?php

    $date = get_field(‘exhibitionstartdate’);

    $y = substr($date, 0, 4);
    $m = substr($date, 4, 2);
    $d = substr($date, 6, 2);

    $time = strtotime(“{$d}-{$m}-{$y}”);

    echo date(‘F n Y’, $time);

    ?>

    thanks a lot

  • Hi @th219,

    When trying to create a PHP datetime object using the DatePicker field, it is recommended to use the following functions:

    $date = DateTime::createFromFormat('Ymd', get_field('exhibitionstartdate'));
    echo $date->format('d-m-Y');
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘date_picker – 1970’ is closed to new replies.