note 26991 deleted from function.strftime by derick
| From: | derick@php.net | Date: | Sun, 14 Aug 2005 12:02:53 +0000 |
| Subject: | note 26991 deleted from function.strftime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93622@lists.php.net to get a copy of this message | ||
Note Submitter: jdavid at NO_SPAM dot skynet dot be
----
If you are using MySQL database timestamps and you wish
to display for example the time and date represented by such
a timestamp, you can use the following function:
function DateAndTime ($timestamp)
{
list($year,$month,$day,$hour,$minute,$second) =
sscanf($timestamp,"%4s%2s%2s%2s%2s%2s");
setlocale("LC_TIME","nl_BE.ISO8859-15@euro");
return strftime("%c",
mktime($hour,$minute,$second,
$month,$day,$year));
}
This function will return the correct date and time in the
locale of your choice, in the default representation.
example:
----------
list($timestamp,$dummy1, ..) = mysql_fetch_row($result);
$displaytime = DateAndTime($timestamp);
echo "The date and time is: $displaytime";
I hope you find this usefull ..