note 49746 deleted from function.date by didou
| From: | didou@php.net | Date: | Mon, 07 Feb 2005 18:57:49 +0000 |
| Subject: | note 49746 deleted from function.date by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84629@lists.php.net to get a copy of this message | ||
Note Submitter: andrei_chirila at yahoo dot com
Reason: bad code
----
This is a function to transform a MySQL timestamp(14) field into a formated date:
<?
function formatDate($mod = 0, $date = 'now')
{
if($date == 'now') { $date = date('YmdHis'); } // if no date set get the
present date as timestamp(14)
$format = array(
"D, jS F Y", // Mon, 7th January 1988
"jS F Y", // 7th January 1988
"j/n/Y", // 7/1/1988
"d-m-Y" // 07-01-1988
// for more formats please read the
//date manual at: http://www.php.net/manual/en/function.date.php
);
if($mod >= count($format)) $mod = 0;
// the index of format starts from 0
$fdate = date($format[$mod], mktime(($date/10000)%100, ($date/100)%100, $date%100,
($date/100000000)%100, ($date/1000000)%100, $date/10000000000 ));
return $fdate;
}
?>