I fixed the timestamp issue.
Actually, Chris is a genius, for contributing the code which I had to modify only slightly.
Here’s the magic line:
$theTime = date("Y-m-d")." ".(date("H")+3).date(":i").date(":s");
Sweet. Cross that off the list! Next up: answer emails…
8 Responses to "I’m a genius"
Added the new code to the comments too… this is a test.
I think your blog is too East coast biased.
That it is, admittedly. However, we’ll see if that east coast bias bites me in the ass when the time is, say, after midnight here. Then the magical code snippet might not work so well. It may not be scalable, as they say. I’ll wait and see what happens tonight after midnight (assuming I’m awake then).
Have you fully tested that solution? The reason I ask is that it appears it would break for posts or comments made in the last 3 hours of a day. For instance, if you post a message at 11pm, it should return an hour value of 26… (23rd hour + 3).
I would suggest this instead:
$time = time() + 10800;
$theTime = date(”Y-m-d H:i:s”,$time);
This should format the string exactly the same as the code you posted, but not have any problems with date roll over. Details are in my comments to the other timestamp post.
Right, that’s what I just said in my comment before yours. I’ll find out tonight.
Sorry, I didn’t see your comment. Probably waited too long between reading and replying. But I wouldn’t bother waiting until late at night to test… Just copy the code snippet somewhere else, and change it to +20 rather than +3. If it breaks with one, it will break with the other, and 20 would break it now, rather than in 14 hours or so.
Does putenv not work in your environment?
/* other time zone */
echo date(”h:i:s”);
/* convert to eastern */
putenv(”TZ=US/Eastern”);
echo date(”h:i:s”);
Well, what we ended up using is this:
$theTime = date(”Y-m-d H:i:s”,time()+10800);