note 11717 modified in str_pad by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Sat, 03 Mar 2001 21:17:51 +0000 |
| Subject: | note 11717 modified in str_pad by jmcastagnetto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11830@lists.php.net to get a copy of this message | ||
To reformat the date "3-3-2001" to "2001-03-03" you would use this regexp:
$newdate = preg_replace("/([0-9]+)-([0-9]+)-([0-9]+)/ie",
"'\\3-'.str_pad('\\2', 2, '0',
STR_PAD_LEFT).'-'.str_pad('\\1', 2, '0', STR_PAD_LEFT)", $date);
http://www.php.net/manual/str-pad.php