I have a table with date/time information stored as strings. Due to poor planning, some of the strings have a timezone in them (e.g., "2014-01-13 04:22 -8"
) and others don't ("2014-01-13 04:22"
). Either type of string works fine with strtotime()
or new DateTime()
but once I do that, the information about whether there was a timezone is lost -- strings without a timezone are assigned the server's default timezone. Is there a function I can use to find out whether the string contains a timezone identifier?
It seems trivial to write a regex for this, but experience tells me that date formats have enough variation and weird special cases that it's always better to use built-in functions when possible.