My Solution to a Date Issue in Dunstan's Time Since Plugin

First, I am not a php programmer. Heck, I am not a programmer in any sense of the word. I hack here and I hack there. But I am not even qualified enough to be called a hacker.

I do, however, adopt early (much to the chagrin of my wife — the pregnant one who wonders why I — I of little ability — spend so much time on the bleeding edge). SVN is my opiate. SVNx is my delivery mechanism.

Recently, I do not know when…something broke with Dunstan’s Time Since. I started getting output of “-1 year 12 months ago.”

Without much effort I found discussions here and here that implicated Brian’s Latest Comments (which I had used then turned off — I didn’t need to be constantly reminded that no one posts comments to or for that matter reads my blog). But much to my chagrin turning off (and even removing entirely) Brian’s Latest Comments did not fix the issue.

And then I found Brian’s fix to Brian’s Latest Comments — specifically designed to play nicer with Dunstan’s Time Since.

And still no help.

At this point in the story one may ask “why not post your question to a forum group”. Well, there is this little warning that I take seriously. It comes in various flavors but is generally along the lines of “Do not use this software unless you know what the term Beta Version means”. Recall from above that I use SVNx. Well I use it on both K2 and WP. As you can see from the footer of this blog, I am at current official release of neither product. I refuse to use the WP forums for the reasons stated here. I refrain from using the K2 forums because I am on an “alpha” release of WP. I refrain from emailing Michael because of the “alpha” thing and because Michael states right in the header to the Dunstan’s Time Since Plugin that he will NOT provide support (see flickr site — now redirected to the K2 forums).

So, I concluded that I was on my own….and deactivated the plugin.

For some reason a few days later, I started thinking that I needed to clear some cache somewhere. I cleared everything I could find but generally speaking, unless one activates a cache plugin, WP doesn’t really have a cache. But while I was desperately searching for a cache, my eye was caught by the little box on the “Options — General” page of the WP Admin area inside the sentence that reads “Times in the weblog should differ by:___ hours.” Being in San Jose, California and having Daylight Savings Time thrust upon me, my little box was filled in with “-7″. I went back to the blog and looked at older posts. The “time since” did not match the difference between my watch and the time-stamp on the posts. It was 7 hours off! Magic!

So, what happens if I set that option to zero? Well … the Time Since problem is solved! Unfortunately, however, the time stamp on the posts now reads UTC. So, this would be fine if I always lived in the UK for winter — but I don’t want to live there. And absolutely not in the winter.

So I set the option back to “-7″ and following the stupid, yet ever appropriate comment of Scott Schnaars, I went back to the “Options — General” page selected “view source”. I found that the variable in question was named “gmt_offset”. I opened up the Dunstan’s Time Since plugin and found the following line of code:

$newer_date = ($newer_date == false) ? (time()+(60*60*get_settings("gmt_offset"))) : $newer_date;

I started playing with the code (insert image of 3 year old with screw-driver disassembling a TV).

Unlike a three year old with a screw-driver I stumbled upon a version of this line of code that lets me keep my “recently-not-all-that-sunny” California address and outputs the correct “time since”:

$newer_date = ($newer_date == false) ? (time()) : $newer_date;

Of course anyone can chime in with whatever they want (see my comment above about no one ever commenting on this blog), but this seems to work for me — at least until I install the next “alpha” release of WP.

So for the two or three people out there that are running WordPress 2.1-alpha1-r3700 and Dunstan’s Time Since. I hope that the above helps.

God knows, there are more of you out there than I can count that have helped me (with many helping on more than one occasion).

3 Responses to “My Solution to a Date Issue in Dunstan's Time Since Plugin”


Leave a Reply

Looking for Something?

About

** |j skwər-ed| n. 1. A forty- something amateur (one lacking the skill of a professional) parent of two beautiful girls (all bias acknowledged). 2. A husband of a bit more than ten years. 3. A partner in the Silicon Valley Office of a Boston Law Firm. 4. A home winemaker. 5. A part-time blogger. Email me.

FlickrRSS

Please install Flash and turn on JavaScript.

Tag Cloud

Ecosafe