This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

time stamp is server time not local time
#1

The time stamps that are being recorded with the comments appear to be the time at the location of my server, not my local time. Is there any way to make them the local time for whoever is viewing my site?

I do have the correct time zone set in Settings->System.
Reply
#2

Did you have the correct time zone set when you posted the comments?

Have you completed the interview?
Reply
#3

Yes. In Settings->System the time zone is set to "US/Pacific". And to double-check I just tried again, posted at 12:05 PM, but it shows up in the comments as posting at 3:05 PM, which is where my server is located.
Reply
#4

Okay. If you preview a comment, does the time show correctly in the preview?

Have you completed the interview?
Reply
#5

Yes. More specifically:
1. If I post a comment it shows the wrong time.
2. If I preview a comment, it shows the correct time while previewing, and when I then post it, it shows the wrong time.
Reply
#6

Okay, so your database server is at a different location to your web server.

Commentics already has a piece of code to deal with this:

PHP Code:
<?php 
@mysql_query("SET time_zone = " . $cmtx_settings->time_zone); //set time zone DB

However it doesn't seem to be working for you. This may be because your server's MySQL setup is missing the time zone definitions.

You could try using an offset instead.

For example, replace that line with this:

PHP Code:
<?php 
@mysql_query("SET time_zone = '-8:00'"); //set time zone DB

Adjust -8:00 accordingly. For example it might be -2:00 or +4:00.

There are 6 places where you will need to make this change:

/comments/includes/commentics.php (line 99)
/comments/rss.php (line 58)
/comments/subscribers.php (line 99)
/comments/vote.php (line 56)
/comments/flag.php (line 59)
/comments/admin/includes/auth.php (line 60)

In the next version, I'll make it so that this can be done via the admin panel.

Have you completed the interview?
Reply
#7

A value of '-7:00' worked nicely.

Of course, that is California's offset from GMT now that we're on daylight savings time. In November, when we go back to standard time, does that mean I'll have to go in and reset this value to '-8:00'?

BTW, thanks for all your help.
Reply
#8

You might try this:

PHP Code:
<?php 
@date_default_timezone_set($cmtx_settings->time_zone); //set time zone PHP
$dst = date('I'); //this will be 1 in DST or else 0
if ($dst) {
@
mysql_query("SET time_zone = '-7:00'"); //set time zone DB (DST)
} else {
@
mysql_query("SET time_zone = '-8:00'"); //set time zone DB (not DST)
}

Have you completed the interview?
Reply
#9

That appears to work nicely. Thanks.
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by And
02-Mar-2021, 05:32 PM
Last Post by cajung
25-May-2012, 07:51 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)