BOAW 0 Report post Posted June 19, 2006 i think i may asked this question awhile back but i never really got it solved. ok..i had a block that told me the server time info or whatever. and the GMT wus at 00:00 i wanted to change it to -5:00 but i didnt know how, so how can i change it? im not sure of the codes in the php to change it to the right GMT time becuase im always gettn the wrong times n day Share this post Link to post Share on other sites
juice 0 Report post Posted October 5, 2006 I have the same problem. The server I am using is five hours behind my local time and I don't know how to change it. But I have a solution - just leave it at the time it is Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted October 5, 2006 It is usually neccesary to adjust the time whenever you use a php time function since it is common to have the server time set to GMT. A typical php code to do that would be something like this: $offset_from_server_time = -6; // a variable defined in the head of the page.. more code here.$my_time = time() + ( 60 * 60 * $offset_from_server_time );.. more code here. See also: http://forums.xisto.com/topic/41773-simple-php-calendar-and-yahoo-calendar-connection-linking-each-date-to-yahoo-calendar/ Share this post Link to post Share on other sites
peroim 0 Report post Posted October 30, 2006 (edited) it isn't hard or so. you just take the servertime and 'add' -5 hours. and since time() gives seconds, that will be -5*60*60 seconds. so here's an example script: <?php$timezone = -5;//rather clear, this is your timezone (in hours) (real timezone)$here = time() + $timezone*60*60;//the time in your timezone, long number, so not good for output;)echo gmdate("l j F Y, h:i A", $here);//echo some time?> gmdate() is exactly the same as date(), but it uses greenwich time, and not servertime. (If using an input time in UNIX-format.)Cya, Peroim Edited October 30, 2006 by peroim (see edit history) Share this post Link to post Share on other sites
electron 0 Report post Posted October 31, 2006 Well your script would give you the time double ahead of the GMT time because you guys are subtracting first and then using gmdate.GMDATE() function requires the current time as per the server.Then accordingly it will find what are the server settings and convert the time and then give the GMT time.So your script is now: gmdate("M d Y H:i:s", mktime()) This is the GMT time as per the server.However if you make a server change the time would go wrong as gmdate takes the servers time settings.But on the same server it is just fine.Hope that helps. Share this post Link to post Share on other sites