note 23569 added to function.mktime

From: Date: Tue, 23 Jul 2002 01:11:02 +0000
Subject: note 23569 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-33394@lists.php.net to get a copy of this message
I found unexpected results with the combination of time(), mktime(), and date(). I'm using a script that gets the last time a user loaded a page and it uses $last_click=time() to store the time since the epoch into a tabble. Ok, so I wanted to make a format of DD.MM.YYYY @ HH:MM:SS so I figured I'd just use: $last_online=date("M.d.Y @ h:i:s", mktime(0, 0, $last_click, 1, 1, 1970); figuring that it would determine the date by the seconds since epoch. Oddly, this always gave me a return that was 20 hours shy. I changed it to: $last_online=date("M.d.Y @ h:i:s",mktime(20, 0, $last_click, 1, 1, 1970) and it did work, but I didn't like the fact that I had to add the extra 20 hours. Then, I realized that mktime() returns seconds as well, so all I had to do was use: date("M.d.Y @ h:i:s", $last_click); I'm not sure why this gave me that response, so if anyone can give me a answer, it would be apreciated. But I just thought I'd share this info in case someone else fell into the same pitfall. -- http://www.php.net/manual/en/function.mktime.php http://master.php.net/manage/user-notes.php?action=edit+23569 http://master.php.net/manage/user-notes.php?action=delete+23569 http://master.php.net/manage/user-notes.php?action=reject+23569

« previous php.notes (#33394) next »