note 14874 added to ref.datetime.php
| From: | william at ScriptingBiz dot Com | Date: | Sat, 18 Aug 2001 23:06:46 +0000 |
| Subject: | note 14874 added to ref.datetime.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16872@lists.php.net to get a copy of this message | ||
Ever use the mysql column type of "timestamp"? It crams all the digits fo the date/time
togeter and makes it hard to deal with. Here's a solution:
#####################################################################
// myts_date is identical to date except that it takes a
// mysql timestamp instead of epoch seconds for an argument
// written by William Janoch - william@ScriptingBiz.Com
//
// I write "clever little" code that never
// complains when the sky isn't falling.
// /* see also "chicken little" code */
function myts_date($format,$mytimestamp)
{
$month = substr($mytimestamp,4,2);
$day = substr($mytimestamp,6,2);
$year = substr($mytimestamp,0,4);
$hour = substr($mytimestamp,8,2);
$min = substr($mytimestamp,10,2);
$sec = substr($mytimestamp,12,2);
$epoch = mktime($hour,$min,$sec,$month,$day,$year);
$date = date ($format, $epoch);
return $date;
}
#####################################################################
http://www.php.net/manual/pt_BR/ref.datetime.php