On 16 January 2004 11:14, Tom wrote:[*snip*]
Is there a way I can force PHP's time functions not to read date strings in the American MM-DD-YYYY format?
Is there a way I can have strtotime read "10-01-2004" (and
all other such
date connotations) as the 10th Jan and not 1st Oct?
No. strtotime() only recognises the formats mm/dd/yyyy, yyyy-mm-dd and yyyymmdd for numeric months; if you use a textual month, you can pretty much put the day, month and year in any order.
Your best bet is to rejig the date into one of the formats recognised before passing it to strtotime -- although, once you've split it into its constituent parts, you might just as well use mktime() to get your timestamp.
And if you just want to insert into mySQL, why not use the mySQL date format specifiers to specify the format of your incoming dates? (Someone else can expound better on this, as I don't use mySQL.)
This will really stump me, and leads me to the conclusion that the only PHP solution is to write my own strtotime function, which is unlikely to be an acceptable answer.
The end user gets to chose their date format, and so if I cannot reverse their arbitrary date format into a timestamp then I have no chance of ensuring that dates are correct.
This seems like a really fundamentally bad thing about PHP :(
I don't suppose there are any PHP classes to hand that connect to mySQL and do all this?