I’m using the jquery calendar picker to get my users to enter dates in the form “dd/mm/yyyy”. I’d like to use php to convert this into a timestamp that I’ll upload to my database. I’m not quite sure what syntax of strtotime that I use so that php knows that my date is in the form above as opposed to, say, the European version mm/dd/yyyy. Any help would be appreciated.
Thanks for the reply! I fear that I’m a bit more versed in PHP at this stage of the game and I’m using PHP to write the date to my database; so it would be much easier if there’s a PHP based solution to convert dd/mm/yyyy from my textfield into a timestamp.
You can’t use strtotime() directly with a dd/mm/yyyy formatted date as it expects that pattern of numbers to (incorrectly for your needs) be mm/dd/yyyy (see date formats). There are a couple of options, including a) using a method specifically designed for getting a date from a specified date format, or b) manipulating the date you have into one that strtotime() will like.
However the above is only available with PHP 5.3, so if you aren’t using something that recent (why not?!), an alternative is to use some string manipulation to coerce the date into the format that suits you.