A comprehensive look at PHP5 DateTime

Posted on

Don't expect to find it here, but Laughine Meme posted the most comprehensive one I could find. You would think that with the introduction in 5.2 of the DateTime and DateTimeZone objects, that date math would be a lot easier in PHP. Unfortunately, the implementation isn't as advanced as I'd expected, maybe a case of high expectations. Dealing with dates,especially once timezones are involed can be very unintuitive, and this doesn't seem to make it noticeably easier.

Beyond adding deltas ("+7 days"), the other common date math is comparing two datetimes, to find out which is more recent, and getting the difference between them. DateTime supports no methods for comparing two datetimes. The simplest solution for doing comparison is to compare epoch seconds.

Buried in the comments, is this most wise bit of advice:

For most everyday issues, use gmdate functions for storage and putenv('TZ=wherever') to make the local presentation correct and you're done. Converting a stored gmdate (say MySQL date/time format) to localtime for a given date string is a matter of appending '+0000′ onto the SQL string, passing it through strtotime, and then use date() on the result. The +0000 forces strtotime into dealing with it as GMT instead of trying to act smart and adding your local offset. Should be easier, but that ain't bad.

Tags: PHP, Programming

─── ✧ ─── ✦ ─── ✧ ───

About the Creation Museum

Posted on

You may not be aware of it, but someone has spent twenty-some million dollars to build a Creation Museum. I hope you take the time to read and enjoy John Scalzi's report about his trip to this shrine to creationsim as much as I did - especially the part about vegeterian dinosaurs.

It's one thing to say to people that God directly created the dinosaurs and that they lived in the Garden of Eden. It's another thing to suggest they lived long enough to harass the Minoans, and do it with a straight face. It's horseshit, pure and simple, but that's not to suggest I can't admire the hucksterism.

Tags: Intelligent Design, Science

─── ✧ ─── ✦ ─── ✧ ───

US Citizen Deported to Mexico

Posted on

It's a scary thought, and something only a few years ago I thought I'd only read in the Onion, but I just read an article about a US Citizen, born in California, that had been wrongly deported to Mexico.  Think it can't happen to you?  Short of always carrying your Passport, or Citizenship Certficate, if you don't look or sound 'merican, how can you prove your a citizen?

On Tuesday, the renewed questions flew from a packed room of journalists: Did ICE cross-reference Pedro's statements with whatever documents exist related to a prior arrest and conviction? Were any efforts made to establish whether he suffers from a mental disability? Did he knowingly sign a voluntary deportation order, or was he somehow coerced? How can this scenario be prevented in the future?

Best line from the Hit and Run discussion: "Finally, the chilling predictions put forth in Cheech Marin's Born in East LA are coming to pass."

Tags: Immigration, Latinos, Politics

─── ✧ ─── ✦ ─── ✧ ───