note 31649 added to function.strftime
| From: | php dot net at frosch dot org | Date: | Tue, 29 Apr 2003 09:06:32 +0000 |
| Subject: | note 31649 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47238@lists.php.net to get a copy of this message | ||
Note to the comment from 'darianlassan at yahoo dot de':
Given a 'bare number' in seconds, e.g. 143567, strftime() will format this number
ACCORDING TO YOUR LOCAL TIMEZONE. Thus, for Germany (where you probably are, since you have a .de
address) you will get an extra hour, since CET is GMT +1.
If you are interested in simply formatting a number to give you hours, minutes and seconds (very
quick for showing time values), then you should ALWAYS use 'gmstrftime' instead, which
will not adjust the time for your local timezone.
Example: I have the decimal value 1.76 minutes returned to me by an application, and want to show
this as MM:SS:
# time value comes as minute value in decimal
$time = 1.76;
# convert to seconds
$min = floor($time);
$sec = round((($time - $min) * 60));
$time_value = ($min * 60) + $sec;
# format using gmstrftime()
$fmt_time = gmstrftime("%M:%S",$time_value);
# display
echo "Time in minutes:seconds = $fmt_time";
cheers,
Nalfy.
--
http://www.php.net/manual/en/function.strftime.php
http://master.php.net/manage/user-notes.php?action=edit+31649
http://master.php.net/manage/user-notes.php?action=delete+31649
http://master.php.net/manage/user-notes.php?action=reject+31649