php - DateTime returns wrong year -
my code following:
<?php $newdate = new datetime('2012'); echo $newdate->format('y');
why $newdate->format('y')
returns 2015 (current year) , not 2012?
because 2012
not valid date string. default date , time set object current, 2015. can hint format going use datetime::createfromformat
$date = datetime::createfromformat('y', '2012'); echo $date->format('y');
Comments
Post a Comment