note 11717 deleted from function.str-pad by felipe
| From: | felipe@php.net | Date: | Sat, 29 Dec 2007 20:26:24 +0000 |
| Subject: | note 11717 deleted from function.str-pad by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134193@lists.php.net to get a copy of this message | ||
Note Submitter: rob at OhReally dot com
----
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);