I’m trying to convert the following XML into a Time:
<time hour="18" minute="05" timezone="Eastern" utc-hour="-4" utc-minute="00" />
I’m parsing the XML using SimpleXML, and storing that in a class. I also tried printing out the following:
print strtotime($x->time->attributes()->hour . ":" . $x->time->attributes()->minute) . "<br>\n";
The results I got from that print looked something like this:
1249254300
I guess the result I’m expecting would be either 18:05 or 6:05 PM
Is there any way I can get it to convert to the style I’m expecting? Also, if I were to add the timezone onto the end is there any way for it to figure that out?
I would advise against using strtotime here. Instead try mktime.
Also you need to format the time stamp (what you printed out was the unix representation). You can do this with the date function.