Question : PHP GMT date Time conversion and display

Hi experts,
 I have the folowing data for date and time. They seem to be local times with the zone info included.
The -06:00 at the end is the GMT offset in hours.
date="2006-04-11-06:00"
time="23:33:00-06:00"
So I like to display "Apr 11 2006, 11:33pm"     from this format "23:59 GMT minus 8"
I am a PHP newbie and the date time functions have me confsed. please help.
thanks

Answer : PHP GMT date Time conversion and display

Hi guyneo,

Here is an example of how to parse the xml you supplied and format the date to your format.

I removed the gmt offset from the output, let me know if you want to include it or not.


Code will produce this output:
----------------------------------------
departure: Apr 11 2006 04:28pm
arrival: Apr 11 2006 05:40pm



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
<?php

$xml = '<responseLeg>
<airline airlineCode="US" airlineName="US Airways" />
<flightNumber>6974</flightNumber>
<equipments>Airbus Industrie A318/A319/320/321</equipments>
<departure date="2006-04-11-08:00" location="LAX" time="16:28:00-08:00" />
<arrival date="2006-04-11-08:00" location="LAS" time="17:40:00-08:00" />
<cabinType>Economy</cabinType>
</responseLeg>';

$xml_array = simplexml_load_string($xml);

foreach($xml_array->departure as $departures){
	echo "departure: " . date('M d Y h:ia',strtotime(substr($departures['date'],0,10) . ' ' . substr($departures['time'],0,8))) . '<br />';
}

foreach($xml_array->arrival as $arrival){
	echo "arrival: " . date('M d Y h:ia',strtotime(substr($arrival['date'],0,10) . ' ' .  substr($arrival['time'],0,8))) . '<br />';
}

?>
Random Solutions  
 
programming4us programming4us