note 46786 added to function.time
| From: | edsarkiss-at-yahoo-dot-com at osu1 dot php dot net | Date: | Sat, 23 Oct 2004 06:41:26 +0000 |
| Subject: | note 46786 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78983@lists.php.net to get a copy of this message | ||
jonatan -- as the docs state, the time() function already returns the "number of seconds since
the UNIX epoch -- Jan 1 1970 00:00:00 GMT".
by applying the local timezone offset to time(), you are actually moving out of GMT.
Here are some things to keep in mind:
1) if you're dealing in UNIX timestamps, the figure is ALWAYS in GMT. There is no notion of
timezone in UNIX timestamps. This is merely a counter of the number of seconds since the epoch.
Timezone is irrelevant. There is no such thing as a UNIX timestamp that is in a different timezone.
2) if you need to convert this to a localized time, then use localtime(time()). This returns an
array of values you may then manipulate or pass to other functions like ....
3) mktime() returns a UNIX timestamp, which means that this is ALWAYS in GMT. The timezone/dst
values that you pass in are taken into consideration, but the value that comes out is a UNIX
timestamp, hence, GMT. see (1) above.
I actually think someone should remove the post from jonatan below, as it is misleading. I know
many engineers (myself included) who are confused by UNIX timestamps at first.
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46786
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46786&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46786&report=yes
Search -- http://master.php.net/manage/user-notes.php