| |||||||||||
| |||||||||||
Local and GMT Time Difference Posted by TedH (TedH), 1 August 2008 Hi, I'm looking at times with a view toward comparing them with a start time, then doing something.The easiest way would seem to be using the base time (no formatting). There is a lot of difference between these and I wonder which is the best one to use. Starting date = 33481731610842121 GMTime = 0001070400 LocalTime = 16541731610842121 My code is this Code:
When I refresh, the Local changes, but the GMT does not. Does that mean the GMT is set to the day (disregarding hours minutes and seconds)? Cheers - Ted Posted by KevinAD (KevinAD), 1 August 2008 Either I'm confused or you are. You are not calling gmtime anywhere in the code you posted and $time has never been defined. Is this what you meant to do?print "Starting date = 33481731610842121<br>\n"; print "GMTime = \n"; print gmtime(time); print "<br>\n"; print "LocalTime = \n"; print localtime(time); gmtime does return a shorter string than localtime, at least on my computer it does. I don't know why that is. But they both return a 9 element array when called in list context and the same format when called in scalar context. print "Starting date = 33481731610842121<br>\n"; print "GMTime = \n"; print scalar gmtime(time); print "<br>\n"; print "LocalTime = \n"; print scalar localtime(time); Posted by admin (Graham Ellis), 2 August 2008 Little demo ...This code: Code:
returns Code:
It looks very odd as a single number all together which can be a bit confusing; elements are really: second minute hour day month (0 to 11) year (from 1900) day of week day of year daylight saving correction Which to use? It depends on the context of your server / computer. If you want it to report back in GMT, then use that ... if it's for a UK only applicatin, then use localtime. Posted by TedH (TedH), 2 August 2008 Hi guys, had major connection problems and it just got sorted (hopefully) by Virgin.You're right Kevin gmtime was missed out - me figuring out stuff, as I've never used this method before. Thanks Graham, I can see what stuff does. There is another one I found that's just "time"and it gives a shorter result. I think that using localtime would be best. Everything is in seconds (I think), and so differences would have to done on that basis. What I'm playing about with is a fake cron thing to activate scripts. Based on a preset date (I'll try to figure out a midnight one). So that oughta tax my brain for a bit (I'm lousy at math) ![]() Thanks - Ted This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |