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 an
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
On 16 December 2004 06:00, neil wrote:
> Hi
>
> I am needing to convert a d/m/y date such as 30/11/2004 into the
> format that mysql can use ie. 2004-11-20
>
> If I try the follow
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.
eg.
list
On Thursday 16 December 2004 14:00, neil wrote:
> I am needing to convert a d/m/y date such as 30/11/2004 into the format
> that mysql can use ie. 2004-11-20
>
> If I try the following:
>
> $testdate="30/11/2004";
> echo date("Y-m-d", strtotime($testdate));
>
> the result is - 2006-06-11
>
> I can
Yeah, this is my problem with relyinig on strtotime(). If you don't give it a
format that it knows, it's going to give you random results (well, not random,
but "undesireable"). Seems like more of a crutch that leaves too much chance
of error for my taste. I prefer to be a little more explici
Hi
I am needing to convert a d/m/y date such as 30/11/2004 into the format that
mysql can use ie. 2004-11-20
If I try the following:
$testdate="30/11/2004";
echo date("Y-m-d", strtotime($testdate));
the result is - 2006-06-11
I can't find any other function apart from strtotime to do this.
An