Top 10 Plugin - Local Time (4 posts)

  1. Jardry
    Posted 8 years ago #

    I've implemented the following Top 10 Pulgin : http://www.alleba.com/blog/2007/03/27/wordpress-plugin-daily-top-10-posts/

    I've asked the author to suggest how the plugin code be edited to reset the daily Top 10 at a specific time each day. My problem is my blog is hosted on a US server, but I'm in Australia.

    My Daily Top 10 gets reset around 2.00pm (Australian Time) which is midnight where the server is.

    I'm not good with coding, I suspect I should be able to add (10hrs * 60mins * 60secs) 36,000 somewhere where it calls the time and checks if it is a "new day".

    Could one of the WP Gurus check it out and advise me if this is possible and if so, where to edit the plugin code.


    Gary O

  2. Doodlebee
    Posted 8 years ago #

    I'm not familiar with that plugin, but you can set your local time with this code:

    print date('F j, Y') . "     " . date('g:i a', $new_U) . " EDT    ";

    Just look for the date(); php code. Most likely, it's formatted something like date('g:1 a');, or if it's using WordPress stuff, you're looking for the_time(); But the above code shows Eastern time based on where the server is located (*3600 = +4 hours)

    Hope that gets you started.

  3. Jardry
    Posted 8 years ago #

    This is the date function within the plugin:

    function todays_date() {
    	$date_array = localtime(time()) ;
    	$month = $date_array[4]+1;
    	if ($month<10) {
    	$month = "0".$month;
    	$day = $date_array[3];
    	if ($day<10) {
    	$day = "0".$day;
    	$year = $date_array[5] + 1900 ;
      $cdate = "$year-$month-$day";
      return $cdate;

    Where and how do I change the above code so as to offset the day to use my localtime rather than the server's time.



  4. Jardry
    Posted 8 years ago #

    I think I have this worked out!

    I added into the $date_array "+(60*60*14.5)":

    $date_array = localtime(time()+(60*60*14.5)) ;

    The server is in Dallas USA which is in timezone GMT -5, I'm in Australia in timezone GMT +9.5, which means I need to add 14.5 * 60 minutes * 60 seconds to get my local time.

    When I uploaded the edited file, it indicated no views to date, then I visited a couple of posts and the counts commenced. I'll check it throughout the day and hopefully when I check tomorrow morning the counts will be lower than what they were late tonight!

Topic Closed

This topic has been closed to new replies.

About this Topic