note 28458 deleted from function.substr by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 07:49:23 +0000 |
| Subject: | note 28458 deleted from function.substr by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72376@lists.php.net to get a copy of this message | ||
Note Submitter: ellipse@optonline.net
----
[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.