WordPress.org

Support

Support » Plugins and Hacks » WordPress Popular Posts » [Resolved] How to change when "day" starts for post stats?

[Resolved] How to change when "day" starts for post stats?

  • I am sure this is simple, but I cannot figure it out…

    My “daily” post stats seem to start over at about 10:00 am or so. So at 9:30 am, it shows the popular posts for the previous 24 hours, but at 10:30, it only shows the popular posts for the last 30 minutes.

    How can I have the stats begin counting at midnight?

Viewing 15 replies - 1 through 15 (of 33 total)
  • Update:

    Not that it matters too much, but I was wrong about what time the plugin starts counting again. It is actually around 9:00 PM (Eastern).

    When does this plugin start to count visits? is it using calendar or it simply starts counting from the day it is installed?

    Example: visits this week are from Monday at 12 AM to Sunday 11:59 PM?

    I am thinking that it must start counting the second it is installed.

    I am going to test it tonight, and empty the cache and historical data at 11:59 pm, and see if that fixes it.

    It’s more likely a time coversion issue. It’s probably resetting at midnight GMT, which right now would be 8pm EDT.

    r3df,

    Yep. You are right. I emptied my cache last night at 11:59 pm, and it started counting again, but the day reset 10 minutes ago, at 8:00 PM EDT.

    So, where can I change the setting in the plugin to reset at midnight EDT?

    Could this bit of code be tweaked to fix this?

    This code is found in: wordpress-popular-posts/wordpress-popular-posts.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    @jeremyers1, I’ve not really had a chance to dig, (I’ve only just started using this plugin myself) but I don’t think the plugin is the issue. I’d suspect it’s the server time, probably is not set for eastern.

    r3df,

    You are probably right. It seems there should be a way to connect the plugin to the Blog Timezone settings instead, or even to the Blog’s Site Stats. I just don’t know enough php to figure it out.

    @jeremyers1, have you checked the times displayed beside the timezone setting in your dashboard under settings->general? Are they correct?

    Do you have access to your database cpanel/phpmyadmin?

    yes, I checked the times in Settings->general. Those are correct.

    Yes, I do have access to my databse phpmyadmin.

    Ok, lets see what time mysql thinks it is. Try entering: SELECT NOW() in the SQL box in myphpadmin and see what time you get.

    Ok, I tested it at 6:58PM Eastern (18:58)

    It came back 22:58:19, which is 10:58. So this is definitely the issue, since my daily stats reset at 8 PM Eastern.

    And now that you have discovered the problem, I was able to set the proper time.

    I used this in the SQL box:

    SET time_zone = 'America/New_York';

    Oh, and for any not in the Eastern Timezone, I think that if you don’t know your named timezone, you can use a UTC offset, such as this:

    SET time_zone = '-5:00';

    if you don’t know your UTC offset, just search Google for it.

    The best solution would be to ask your hosting provider to fix it on the server.

    Did the set work? Try select now() again afterwards, it should be back at it’s old time. The set does not stick for me, which as as per the docs as I understand it. The SET time_zone is a per session setting, and unfortunately in php/web, an sql session is usually per page load.

    You’ll need to put something like:
    $wpdb->query(“SET time_zone = ‘America/New_York'”);
    in either this plugin, or your functions.php to set it every time a page loads. (depending on where you put it, you may need: global $wpdb; before it too.)

Viewing 15 replies - 1 through 15 (of 33 total)
  • The topic ‘[Resolved] How to change when "day" starts for post stats?’ is closed to new replies.
Skip to toolbar