tedd wrote:
> At 3:40 PM +0530 8/17/09, kranthi wrote:
>> dont you think http://in3.php.net/strtotime is a solution to your
>> problem ?
> No, it's not a solution to my problem -- I have he problem solved.
> I was just asking if anyone wanted to submit their php solution. It was
> only an exercise.
> I know there are numerous javascript solutions (some good, some bad),
> but ALL of their data has to be accepted and scrubbed by a php script
> anyway, so I was suggesting creating a php script to do it.
> If it's not a good exercise, then don't do it.

First stab at it.  Of course it needs US date ordering (month day year).
 You can't do euro type dates or any other format because there is no
way to tell the difference between 1/2/2009 (January) and 1/2/2009


$dates = array(
'August 5, 2009',
'Aug 05 2009',
'Aug 5, 9',
'8 05 2009',

foreach($dates as $date) {
    $date = preg_replace("#([\d])+[^/\d]+([\d]+)[^/\d]+([\d]+)#",
"$1/$2/$3", $date);
    echo date("M j, Y", strtotime($date)) ."\n";



PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to