On my website we store all time & date in the following format:
Table Column: Date – 16.01.2012
Table Column: Time – 06:36:50pm
This has been causing problems with those who live in different timezones, therefore we are looking at changing this to simple time() strings, however because theres a lot of content on our site that already has such time(old, not time() strings) in the database, we want to keep that data and therefore are wondering how we can go about changing those strings into time().
I understand how to update databases and all, I am lost on actually converting 16.01.201206:36:50pm into its respective time() string, as strtotime likes things to be perfect.
Thank you for your time, and I look forward to your suggestions.
Are you asking how to make the conversion in the database, or how to convert a datetime from the database when it gets loaded into your PHP?
If it’s the latter, there are lots of ways that you can format your date.
Taken from the comments of the PHP manual for date_format:
These are just some examples. Take a look at this page for some more ideas.
Edit based on comment:
You can use DateTime::createFromFormat, which allows you to specify the format of the datetime that you are passing in.