At 10:43 AM -0500 8/19/09, Shawn McKenzie wrote:
 > 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
 (February):

 <?php

 $dates = array(
 'August 5, 2009',
 'Aug 05 2009',
 'Aug 5, 9',
 '08/05/09',
 '8-5-9',
 '8 05 2009',
 '8,5,9',);

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

 ?>


Guess you didn't like this one?  Also, if you change the / to - in the
preg_replace() it should work on Euro style dates.

$date = preg_replace("#([\d])+[^-\d]+([\d]+)[^-\d]+([\d]+)#",
"$1-$2-$3", $date);

-Shawn

-Shawn:

Thanks, but my idea was more along the lines of this:

http://php1.net/b/date-picker/index.php

It's not thoroughly tested, but thus far it works.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

Reply via email to