Date Bug
-
Hi I have a client that lives in UK and the web server is in California. I know you have addressed time zones issues however there still is a bug I am experiencing. And yes I do have the latest version. (1.1)
Basically when you get the date from the wordpress function, which does account for time zone settings set in wordpress General Settings, on about line 55 in st-daily-tip_backup.php I see it is used to query the database to find the tip for that day. However further in the code when you account for the tip being set to display yearly you offset the display_date to next year while grabbing the current date based on the web server not wordpress.
This means that if my web server is on one side of the world and someone has set their wordpress settings to their time zone and they are on the other side of the world (ahead in time zones) there will be approximately 12 hours where the tip will not show.
To fix this I simply got the wordpress (time and date based) $todate variable and replaced the year part of the string with the next year and stored it in $yearlaterdate. Before it updates yesterday’s date with the new date which is a year ahead.
//CLEAR OUT THE YEAR
$todate = substr($todate, 4);//GET THE WORDPRESS YEAR
$wordPressYear = the_time(“Y”);//SET TO NEXT YEAR
$wordPressYear += 1;//PUT NEXT YEAR ON THE DATE
$yearlaterdate= $wordPressYear . $todate;$wpdb->query(“UPDATE $table_name SET display_date = ‘$yearlaterdate’ WHERE ID = ” . $tips[‘id’]);
- The topic ‘Date Bug’ is closed to new replies.