note 23075 added to function.substr
| From: | bort at thebort dot com | Date: | Tue, 09 Jul 2002 00:08:21 +0000 |
| Subject: | note 23075 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32761@lists.php.net to get a copy of this message | ||
Hey for those who may be sort of noobies at php I wrote this handy function to change a mysql date
2002-07-09 into 07/09/2000 using a custom php function. To use it just put in :
echo formatmysqldate(<date variable goes here>);
Heres the function and enjoy:
function formatmysqldate($date) {
$year = substr($date, 0, 4);
$month = substr($date, -5, 2);
$day = substr($date, 8, 9);
echo $month;
echo "/";
echo $day;
echo "/";
echo $year;
}
--
http://www.php.net/manual/en/function.substr.php
http://master.php.net/manage/user-notes.php?action=edit+23075
http://master.php.net/manage/user-notes.php?action=delete+23075
http://master.php.net/manage/user-notes.php?action=reject+23075