How can I convert string “M-d-Y::H:i:s” to unix timestamp in php. I just realized manipulating date and time must be the most time consuming entity in any programming language.
Trivial Question: Why do you think there isn’t any universal date time format. Why are there so many variations of same data? AArrhh.
The OOP way (requires PHP >= 5.3.0):
You should of course check the return value of
createFromFormat(it’sfalseif an error occurs) but you should also definitely checkDateTime::getLastErrors(); otherwise you might be surprised if e.g. your input has a day of “Jan 32”. See my answer here for more info.