note 28458 modified in function.substr by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 07:48:09 +0000 |
| Subject: | note 28458 modified in function.substr by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72375@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:
<?php
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--
[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.
http://php.net/manual/en/function.substr.php