Question

Short story: the guy that originally wrote this code was [and probably still is] pants-on-head retarded.

The code in question receives payment events from our provider and logs them into the database with the format: 'o-m-d H:i:s'

This is all well and good, except the %o modifier will give you a different year if the ISO-8601 week "belongs" to a different year. [Reference]

Case in point: we have payments logged for 2013-12-31 which, in normal/not-crazy-person date, should be 2012-12-31. So for all intents and purposes we see what appear to be payments happening in the future, and occasionally in the past.

The real problem here is that I cannot find any date parsing function in PHP or mySQL that will interpret the %o flag, thus preventing me from re-formatting these dates back into something sane.

Does anyone know how to get these dates interpreted properly?

Was it helpful?

Solution

No, nothing I know of. However, doing a grep for all your files for o-m-d, which is a rather unique term, should solve you 98% of your problems through the entire codebase.

If you're using a VCS (and since you sound like a sane person, you probably are), make a commit, grep (or super-search-and-replace), and see if it works better for you, if it does, commit, if not, discard. It's really as simple as that.

If that doesn't work for you... Well... May God have mercy upon your soul.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top