Sunday, 15 September 2013

String to Time, but without the limitations of strtotime()

String to Time, but without the limitations of strtotime()

In my (non-public) applications, I like for my users to be able to enter
the date/time in whatever format and then use strtotime() along with
date() to translate it to YYYY-MM-DD for DB storage. I know this has a
couple of drawbacks (such as how 1/1/13 vs. 1-1-13 might be handled based
on locale and such), but over the years these have never been an issue
given my user base.
However, there is one issue that I may have to resolve, and that's with
handling dates prior to 1970 in one particular application. For obvious
reasons, strtotime() doesn't work so well. I know I could use a
date-picker, but was wonder if there is a more proper way of handling this
that would allow me to do what I've been doing but to handle a wider range
of dates.

No comments:

Post a Comment