I have a date in the following format
November 18, 2009, 3:00PM
How can i break that up so that i can store each value as its own variable?
such as...
$month //November
$day //18
$year //2009
$hour //03
$minute //00
$ampm //PM
---------------Solution----------------
$startdate = "November 18, 2009, 3:00PM";
list($month,$day,$year,$time) = preg_split('/[ ,]/',$startdate,false,PREG_SPLIT_NO_EMPTY);
preg_match('/([0-9]+):([0-9]+)([AP]M)/',$time,$timeparts);
list($time,$hour,$minute,$ampm) = $timeparts;
$curdate = date_parse($startdate);
$month returns the "November", but in my specific application i needed the number, so i used the date_parse function to do that.
$current_month = $curdate[month];
$month // November
$day // 18
$year // 2009
$hour // 3
$minute // 00
$ampm // PM