note 28458 modified in function.substr by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Tue, 14 Jan 2003 06:50:14 +0000 |
| Subject: | note 28458 modified in function.substr by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42097@lists.php.net to get a copy of this message | ||
[Editor's note: You can also use the MySQL function UNIX_TIME)) along with the PHP function
date(), or for an even simpler solution, the MySQL DATE_FORMAT(), see: http://www.mysql.com/doc/en/Date_and_time_functions.html
for more details.]
Here is a handy function, at least to me it is, to convert mysql returned timestamp(14) data-type
into yyyy-mm-dd hh:mm:ss format:
function get_DateTime ($string)
{
$yyyy = substr($string, 0,4);
$month = substr($string, 4,2);
$dd = substr($string, 6,2);
$hh = substr($string, 8,2);
$mm = substr($string, 10,2);
$ss = substr($string, 12,2);
$ftime = "$yyyy-$month-$dd $hh:$mm:$ss";
return $ftime;
}
Pretty much self-explanatory.
--was--
Here is a handy function, at least to me it is, to convert mysql returned timestamp(14) data-type
into yyyy-mm-dd hh:mm:ss format:
function get_DateTime ($string)
{
$yyyy = substr($string, 0,4);
$month = substr($string, 4,2);
$dd = substr($string, 6,2);
$hh = substr($string, 8,2);
$mm = substr($string, 10,2);
$ss = substr($string, 12,2);
$ftime = "$yyyy-$month-$dd $hh:$mm:$ss";
return $ftime;
}
Pretty much self-explanatory.
http://www.php.net/manual/en/function.substr.php