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 explicit:
list($day,$month,$year) = explode("/",$testdate);
echo date("Y-m-d", mktime(0,0,0,$month,$day,$year));
Try that out. mktime() produces a serial date/time just like strtotime() but
you have a little more control over what it's producing and subsequently what
gets piped into date(). This exact example is what I used once before when
arguing against using strtotime(). Most people are going to use a 'normal'
format that strtotime() likes, but the format you're using (european standard?)
and just using the numbers is the one big instance that strtotime() breaks.
Hope this helps. You should be able to get whatever date format you need now.
*** new email address [EMAIL PROTECTED]
*** old email address [EMAIL PROTECTED] YAY CHAPTER 11! :(
= = = Original message = = =
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:
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.
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php