php - date_create_from_format is returning wrong day -
i facing issue date_create_from_format php. here code:
date_default_timezone_set('asia/kathmandu'); $date = date_create_from_format('d/m/y h:ia', '28/05/2016 15:24pm'); echo date('d/m/y h:ia',$date->gettimestamp()); //returns 29/05/2016 03:24am
i trying change 24 hour time 12 hour. working.thanks.
you must create date 1 type. use pm-am or 24h format. otherwise 15:43 pm = 12:43 pm + 3 hour.
try this:
$date = date_create_from_format('d/m/y h:i', '28/05/2016 15:24');
update
if not control input data, can use crutch:
$date = date_create_from_format('d/m/y h:i', substr('28/05/2016 15:24pm', 0, -2));
Comments
Post a Comment