Re: [PHP-DB] date conversions

2004-12-15 Thread Jason Wong
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

Re: [PHP-DB] date conversions

2004-12-15 Thread neil
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

RE: [PHP-DB] date conversions

2004-12-16 Thread Ford, Mike
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

Re: [PHP-DB] date conversions

2004-12-15 Thread tg-php
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

Re: [PHP-DB] date conversions

2004-12-16 Thread tg-php
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