I am calling nodes from XML <observation_time>2014-02-19T22:56:00Z</observation_time>
with a line that looks like $lasobs_time=$lasxml->data->METAR->observation_time;
. That line of code works like a champ, and I am able to INSERT INTO my database just fine.
I am wondering if there is a way to turn the observation_time: 2014-02-19T22:56:00Z in to more than 4 fields/variables I would be able to work with a little better; Maybe $obsyear: 2014 $obsmonth: 02 $obsday: 19 $obstime: 2256 UTC.
Would explode
be the best option? How would I go about it?
date_parse_from_format()
should do the trick.
$date = date_parse_from_format("Y-m-d\TH:i:sT", $lasxml->data->METAR->observation_time);
$obsyear = $date["year"];
$obsmonth = $date["month"];
$obsday = $date["day"];
$obstime = "$date[hour]$date[minute]";