pagegen Posted August 10, 2010 Share Posted August 10, 2010 Hey, I have been reading an xml which has time like this '1057' which us '10:57' I need a time function which will make it like '10:57' from '1057' I have tried stuff like date('h:m', '1057') but no luck Thank you Link to comment https://forums.phpfreaks.com/topic/210307-time/ Share on other sites More sharing options...
MadTechie Posted August 10, 2010 Share Posted August 10, 2010 date will work with seconds so your be better off spliting ie $date = "1057"; $newdate= preg_replace('/(\d\d)(\d\d)/im', '\1:\2', $date); echo $newdate; using a regex is overkill so substr would also work well $date = "1057"; echo substr($date, 0, 2).":".substr($date, 2, 2); Link to comment https://forums.phpfreaks.com/topic/210307-time/#findComment-1097432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.