This is a script I use on my forum. I live in Melbourne, the forum is hosted in the US, time difference = 14 hours...
<?php
$serverdate = date("l, d F Y h:i a");
echo 'Unadjusted Server Date: <b>'.$serverdate.'</b>';
echo ' <p>';
// 14 = hours difference between server time and local time
$timeadjust = (14 * 3600);
$melfullbdate = date("l, n M Y h:i a",time() + $timeadjust);
$month = date("M",time() + $timeadjust);
$day = date("j",time() + $timeadjust);
echo '<pre>Month & Day for Script:.......... '.$month.' '.$day;
echo '<br>Full Melbourne Date:............. '.$melfullbdate .'</pre>';
?> I hope it helps.
I've got something a little weird that I can't quite explain.
We've got two installs of the forums using the one database. the older one can be found here: lansmash.com/v and the newer one here arena.lansamsh.com/v/
The newer installation thinks it's 10 hours ahead of the older one, but I can't figure out where in the code it's getting the change from!
@jroos My method is add date_default_timezone_set() in the conf/database.php (it makes all database's time correct.) My forum's member are live in Taiwan, so I add date_default_timezone_set('Asia/Taipei'); after the <?php Since my forum hosted in USA, time different 16 hours (Taiwan's hour - USA's hour = 16), it will have some problems in account profile. So I edit the themes/account_profile.php and themes/search_results_users.php, find any mktime() and change to mktime(date('H')-16). example: Change <p>'.TimeDiff($this->Context, $this->User->DateFirstVisit, mktime().'</p> to <p>'.TimeDiff($this->Context, $this->User->DateFirstVisit, mktime(date('H')-16)).'</p>
so for being a pain in this thread . . .
If I replace line 94 in comments.php as mentioned by minisweeper:
<span>'.$this->Context->GetDefinition('CommentTime').'</span>'.date('F dS Y h:i:s A', $Comment->DateCreated);
The time is 2 hours off.
Then I added date_default_timezone_set('America/New_York); to the database.php in conf. So it fixed the issue - but all previous posts will be 2 hours off.
Comments
I do that so you know what time it is at this end!
Posted: Saturday, 13 January 2007 at 4:36PM (Australian Eastern Daylight Savings Time)
I live in Melbourne, the forum is hosted in the US, time difference = 14 hours...
<?php $serverdate = date("l, d F Y h:i a"); echo 'Unadjusted Server Date: <b>'.$serverdate.'</b>'; echo ' <p>'; // 14 = hours difference between server time and local time $timeadjust = (14 * 3600); $melfullbdate = date("l, n M Y h:i a",time() + $timeadjust); $month = date("M",time() + $timeadjust); $day = date("j",time() + $timeadjust); echo '<pre>Month & Day for Script:.......... '.$month.' '.$day; echo '<br>Full Melbourne Date:............. '.$melfullbdate .'</pre>'; ?>
I hope it helps.
Posted: Tuesday, 17 April 2007 at 7:59AM
We've got two installs of the forums using the one database. the older one can be found here: lansmash.com/v and the newer one here arena.lansamsh.com/v/
The newer installation thinks it's 10 hours ahead of the older one, but I can't figure out where in the code it's getting the change from!
My method is add date_default_timezone_set() in the conf/database.php (it makes all database's time correct.)
My forum's member are live in Taiwan, so I add
date_default_timezone_set('Asia/Taipei');
after the<?php
Since my forum hosted in USA, time different 16 hours (Taiwan's hour - USA's hour = 16), it will have some problems in account profile.
So I edit the themes/account_profile.php and themes/search_results_users.php, find any mktime() and change to mktime(date('H')-16).
example:
Change
<p>'.TimeDiff($this->Context, $this->User->DateFirstVisit, mktime().'</p>
to<p>'.TimeDiff($this->Context, $this->User->DateFirstVisit, mktime(date('H')-16)).'</p>
and leave timezone as is