note 26991 added to function.strftime
| From: | jdavid at NO_SPAM dot skynet dot be | Date: | Tue, 19 Nov 2002 21:47:45 +0000 |
| Subject: | note 26991 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39712@lists.php.net to get a copy of this message | ||
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 ..
--
http://www.php.net/manual/en/function.strftime.php
http://master.php.net/manage/user-notes.php?action=edit+26991
http://master.php.net/manage/user-notes.php?action=delete+26991
http://master.php.net/manage/user-notes.php?action=reject+26991