note 31649 deleted from function.strftime by derick

From: Date: Sun, 14 Aug 2005 12:04:08 +0000
Subject: note 31649 deleted from function.strftime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93626@lists.php.net to get a copy of this message
Note Submitter: php dot net at frosch dot org ---- 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.

« previous php.notes (#93626) next »