Possible Duplicate:
Convert one date format into another in PHP
I know there are plenty of posts out there, however there is not any validated or accepted answer that explains that well!
I'm working with Wordpress and use this to save a date into a database …
update_post_meta($post->ID, "event_date", $_POST["_wr_event_date"]);
I simply put in my desired date like 08.05.2012 into the _wr_event_date
Field and it successfully gets stored into the database. However for further stuff I need this date to be sortable and I want to convert it into a unix timestamp.
How can I convert my entered date value "08.05.2012" (which is in german date format: %d.%m.%Y) to a unix timestamp that represents this time?
I thought of using pdate_post_meta($post->ID, "event_date", strtotime($_POST["_wr_event_date"]));
but I wonder if this is the correct way because I can't think of a reason why strtotime()
should automagically know what date format I've put in!?
Any thoughts on that? thank you in advance.