I noticed that strtotime()
handles unix timestamps in an odd way, and I was curious if anyone knows why that is:
var_export(strtotime('1330725042')); // false
var_export(strtotime('@1330725042')); // 1330725042
Why does strtotime()
return false
when given a unix timestamp (unless said timestamp is prefixed by @
)?
This is from the internals of a library method that I built that is intended to "resolve" an unknown-format variable into a timestamp. Using a bare strtotime()
isn't helpful in this case because it returns the wrong result when the incoming value actually is a timestamp.
I've reworked the library method to do an explicit check for a timestamp-like value and return it unmodified, so there's... shall we say, no practical application for this question anymore; I'm just curious.