iam rockstar
iam rockstar

Reputation: 15

function getTimestamp() on a non-object

i assign a date as string to the datetimepicker 16/01/2016 09:34:02

$ddate=get_field('ddate',$post->ID);
echo $ddate;
$ddate=date_create_from_format('d/m/Y H:m:s',$ddate);   

var_dump($ddate);

but in var_dump i get the output as object(DateTime)#725 (3) { ["date"]=> string(26) "2018-10-16 09:00:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } but when i echo the ddate it echos is correctly.

basically the wrong date i am unable to figure out the error plz guide

Upvotes: 0

Views: 200

Answers (1)

Karthick Paramasivam
Karthick Paramasivam

Reputation: 176

Change the minutes format from "m" to "i".

$ddate="16/01/2016 09:34:02";
$ddate=date_create_from_format('d/m/Y H:i:s',$ddate);
var_dump($ddate);</code>

Please refer the formats here.

Upvotes: 1

Related Questions