parsing - False dateresult using date() php -
i want parse date 1938
1938+02:00
using date()
& strtotime()
.
my code:
echo date("y", strtotime("1938+02:00"));
gives me result "2014"..
what doing wrong?
for first 4 characters of string. no need work dates , such:
echo substr('1938+02:00', 0, 4);
demo
but if insist on using date functionality you'll need utilize datetime::createfromformat()
date string not standard format.
$date = datetime::createfromformat('yp', '1938+02:00'); echo $date->format('y');
demo
php parsing date strtotime
No comments:
Post a Comment