Interesting use of split().. don't think I've ever used that function but looks 
like it'll do just as well and also allow multiple dividers.  Thanks for 
pointing that out.

As for this:

$mysqldate = $y.'-'.$m.'-'.$d;

The only problem I foresee is what happens when you have single digit days and 


What does MySQL do with this?

What happens if you want the date in another format?  It'll take another minute 
or two (and leave more potential for typing errors I think) if you did your 
date format like this rather than using date() + mktime().   I think 
date/mktime gives you more reliability and more flexibility.   Just something 
to think about.  When it comes down to it, whatever works for you, right? :)


= = = Original message = = =

Thank you for all your help.

Among all  the variations I found this to be the clearest:

list($d,$m,$y) = explode("/",$testdate);
$mysqldate = date("Y-m-d", mktime(0,0,0,$m,$d,$y));

But I also thought the use of split instead of explode so you could nominate
multiple delimiters was good.
list($d,$m,$y) = split('[/.-]', $testdate);

Another variation was to hardcode the date results instead of using the date
function which is very simple:
$mysqldate = $y.'-'.$m.'-'.$d;

Sorry for asking a question that is obviously asked often.

Interesting comment on 'normal'. I suspect that numerically more of the
world uses dmy than mdy. There is a lot more of the world outside the US
than in it.

Thanks again for all your help.


Sent by ePrompter, the premier email notification software.
Free download at

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to