Re: [PHP] gmtime?
> > -Original Message- > > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > > Sent: 27 May 2002 12:48 > > > > > > -Original Message- > > > > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > > > > Sent: 24 May 2002 20:31 > > > > > > > > time() returns the number of seconds since the Unix Epoch to > > > > the current > > > > local time > > > > > > > > gmtime() should return the number of seconds since the Unix > > > > Epoch to the > > > > current GM-time > > > > > > > > Do you understand now? > > > > > Uh, no, actually now I'm more confused! > > > > I can understand that you're confused. :-) Or am I? > > > > > As I understand it, a Unix timestamp is *always* the number > > > of seconds since 1-Jan-1970 GMT ("the Unix epoch"), and > > > so is always a GMT time. > > > > Imho no, because 1-Jan-1970 GMT is just the "starting point", > > the result depends on which timezone your server is located in. > > Please correct me if I'm wrong here! > > Well, I'm not sure, because I think we're talking at cross purposes. I'm *still* not sure what you want gmtime() to achieve that's different from time(), because, as far as I can see, the two scenarios you describe above actually return the same value. Or, to put it another way, because a timestamp is *always in GMT*, it returns the time since 1-Jan-1970 00:00:00, full stop, period, end of story. In other words, timestamps operate in a single timezone, and it's up to anything else that works with a timestamp to do the timezone (and daylight-savings) corrections. (This is also why you get the anomaly of 23- and 25-hour days in areas which have daylight-savings timeshifts.) > > Let's take some detailed examples, and maybe you can explain what you're trying to get with your gmtime() (and why!): > > In a purely GMT zone, with local time 27-May-2002 12:00:00, the UNIX timestamp is 1022500800. > > In a nominally GMT zone, but with daylight-savings in effect (such as British Summer Time!), with local time 27-May-2002 13:00:00, the UNIX time stamp for this is also 1022500800. > > Likewise, in a GMT+0200 zone, a local time of 27-May-2002 14:00:00 also gives a timestamp of 1022500800. > > In fact, this same timestamp of 1022500800 also represents all of these local times: > > 27-May-2002 04:00 -0800 > 27-May-2002 07:00 -0500 > 27-May-2002 17:00 +0500 > 27-May-2002 23:00 +1100 > > and even such oddities as: > > 27-May-2002 21:30 (Western Australia / Northern Territory) > > Thus, given the timestamp of 1022500800, it's the job of date() to determine the correct timezone and daylight-savings offset and apply them before formatting the output; gmdate() just formats it without applying any offsets. Likewise, mkdate() and gmmkdate() translate the other way respectively with and without timezone correction. > > Forgive me if I've gone on at what seems like excessive length, but I just wanted to make sure we both know exactly what it is we're talking about! > > Cheers! > > Mike > @matt&mike: Thank you for your explanations. I'm a bit sorry for having asked such a question. The deeper I thought about it the more confused I was. I see now that there's no sense in a function like gmtime(). Sorry. Jens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] gmtime?
> -Original Message- > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > Sent: 27 May 2002 12:48 > > > > -Original Message- > > > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > > > Sent: 24 May 2002 20:31 > > > > > > time() returns the number of seconds since the Unix Epoch to > > > the current > > > local time > > > > > > gmtime() should return the number of seconds since the Unix > > > Epoch to the > > > current GM-time > > > > > > Do you understand now? > > > Uh, no, actually now I'm more confused! > > I can understand that you're confused. :-) Or am I? > > > As I understand it, a Unix timestamp is *always* the number > > of seconds since 1-Jan-1970 GMT ("the Unix epoch"), and > > so is always a GMT time. > > Imho no, because 1-Jan-1970 GMT is just the "starting point", > the result depends on which timezone your server is located in. > Please correct me if I'm wrong here! Well, I'm not sure, because I think we're talking at cross purposes. I'm *still* not sure what you want gmtime() to achieve that's different from time(), because, as far as I can see, the two scenarios you describe above actually return the same value. Or, to put it another way, because a timestamp is *always in GMT*, it returns the time since 1-Jan-1970 00:00:00, full stop, period, end of story. In other words, timestamps operate in a single timezone, and it's up to anything else that works with a timestamp to do the timezone (and daylight-savings) corrections. (This is also why you get the anomaly of 23- and 25-hour days in areas which have daylight-savings timeshifts.) Let's take some detailed examples, and maybe you can explain what you're trying to get with your gmtime() (and why!): In a purely GMT zone, with local time 27-May-2002 12:00:00, the UNIX timestamp is 1022500800. In a nominally GMT zone, but with daylight-savings in effect (such as British Summer Time!), with local time 27-May-2002 13:00:00, the UNIX time stamp for this is also 1022500800. Likewise, in a GMT+0200 zone, a local time of 27-May-2002 14:00:00 also gives a timestamp of 1022500800. In fact, this same timestamp of 1022500800 also represents all of these local times: 27-May-2002 04:00 -0800 27-May-2002 07:00 -0500 27-May-2002 17:00 +0500 27-May-2002 23:00 +1100 and even such oddities as: 27-May-2002 21:30 (Western Australia / Northern Territory) Thus, given the timestamp of 1022500800, it's the job of date() to determine the correct timezone and daylight-savings offset and apply them before formatting the output; gmdate() just formats it without applying any offsets. Likewise, mkdate() and gmmkdate() translate the other way respectively with and without timezone correction. Forgive me if I've gone on at what seems like excessive length, but I just wanted to make sure we both know exactly what it is we're talking about! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] gmtime?
Unix epoch is the number of secs since the start date in GMT regardless of where your server is. The timestamp is a GMT value. Matt Friedman Web Applications Developer www.SpryNewMedia.com -Original Message- From: Jens Lehmann [mailto:[EMAIL PROTECTED]] Sent: Monday May 27, 2002 7:48 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] gmtime? > > -Original Message- > > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > > Sent: 24 May 2002 20:31 > > > > time() returns the number of seconds since the Unix Epoch to > > the current > > local time > > > > gmtime() should return the number of seconds since the Unix > > Epoch to the > > current GM-time > > > > Do you understand now? > Uh, no, actually now I'm more confused! I can understand that you're confused. :-) Or am I? > As I understand it, a Unix timestamp is *always* the number > of seconds since 1-Jan-1970 GMT ("the Unix epoch"), and > so is always a GMT time. Imho no, because 1-Jan-1970 GMT is just the "starting point", the result depends on which timezone your server is located in. Please correct me if I'm wrong here! > Any function that converts between local time and a Unix > timestamp therefore has to take the current timezone (and > any daylight-savings rules) into account. This is why there > are two versions of mktime() and date(), but only one time(). > > Cheers! > > Mike > Jens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gmtime?
> > -Original Message- > > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > > Sent: 24 May 2002 20:31 > > > > time() returns the number of seconds since the Unix Epoch to > > the current > > local time > > > > gmtime() should return the number of seconds since the Unix > > Epoch to the > > current GM-time > > > > Do you understand now? > Uh, no, actually now I'm more confused! I can understand that you're confused. :-) Or am I? > As I understand it, a Unix timestamp is *always* the number > of seconds since 1-Jan-1970 GMT ("the Unix epoch"), and > so is always a GMT time. Imho no, because 1-Jan-1970 GMT is just the "starting point", the result depends on which timezone your server is located in. Please correct me if I'm wrong here! > Any function that converts between local time and a Unix > timestamp therefore has to take the current timezone (and > any daylight-savings rules) into account. This is why there > are two versions of mktime() and date(), but only one time(). > > Cheers! > > Mike > Jens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] gmtime?
> -Original Message- > From: Jens Lehmann [mailto:[EMAIL PROTECTED]] > Sent: 24 May 2002 20:31 > > time() returns the number of seconds since the Unix Epoch to > the current > local time > > gmtime() should return the number of seconds since the Unix > Epoch to the > current GM-time > > Do you understand now? Uh, no, actually now I'm more confused! As I understand it, a Unix timestamp is *always* the number of seconds since 1-Jan-1970 GMT ("the Unix epoch"), and so is always a GMT time. Any function that converts between local time and a Unix timestamp therefore has to take the current timezone (and any daylight-savings rules) into account. This is why there are two versions of mktime() and date(), but only one time(). Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gmtime?
> I don't know what gmtime() is supposed to do. But is gmmktime() similar? > http://www.php.net/manual/en/function.gmmktime.php > -Kevin Sorry, my first answer was incorrect. gmmktime() does not do what I want. Do you have any other suggestion why we need/don't need gmtime()? Jens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gmtime?
> I don't know what gmtime() is supposed to do. But is gmmktime() similar? time() returns the number of seconds since the Unix Epoch to the current local time gmtime() should return the number of seconds since the Unix Epoch to the current GM-time Do you understand now? gmmktime() does exactly what I want if I don't pass arguments but since this behaviour is not documented it's probably confusing to a lot of people, isn't it? Jens Lehmann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gmtime?
> Did you see gmdate()? > http://www.php.net/manual/en/function.gmdate.php Yes, of course. I can do time()-date("Z") to have gmtime (or maybe) something better, but wouldn't it be better to have gmtime() implemented anyways? Please tell me if I missed something. Thank you. Jens Lehmann PS: date("U") and gmdate("U") return the same results -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] gmtime?
Did you see gmdate()? http://www.php.net/manual/en/function.gmdate.php -Original Message- From: Jens Lehmann [mailto:[EMAIL PROTECTED]] Sent: May 24, 2002 2:52 PM To: [EMAIL PROTECTED] Subject: [PHP] gmtime? Any reasons why there's no gmtime()-function in PHP? I'd like to hear your thoughts. Jens Lehmann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php