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');