Preg_split to be used to process date
Posted: Sat Jun 27, 2009 9:10 pm
January 1, 2008
June 25, 2009 - 8:24 am
I need to break down the first date into 3 arrays, Month, Date, year.
And the second one the same way, but the time could be ignored.
This is what i've done so far
this processes the mysql datetime format, (0000-00-00 00:00:00) properly, but i dont know how to make a regex to process a format that looks like this (June 25, 2009) or (June 25, 2009 - 8:24 am). So i basically need help with this regex. Someone recommended using strtotime() but that only returns a date if true/false. I need a preg_split with regex. thanks.
June 25, 2009 - 8:24 am
I need to break down the first date into 3 arrays, Month, Date, year.
And the second one the same way, but the time could be ignored.
This is what i've done so far
Code: Select all
$datenow = mktime (date("h"),date("i"),date("s"),date("m"),date("d"),date("Y"));
list($year,$month,$day,$hour,$minutes,$seconds) = preg_split('/[ :-]+/', $datenow);