brown2005 Posted November 15, 2007 Share Posted November 15, 2007 hi, can anyone show me a function to change dd/mm/yyyy to yyyy-mm-dd thanks Quote Link to comment Share on other sites More sharing options...
revraz Posted November 15, 2007 Share Posted November 15, 2007 One way is to explode it on "/" and then just re-output it with "-" Quote Link to comment Share on other sites More sharing options...
brown2005 Posted November 15, 2007 Author Share Posted November 15, 2007 hi, would anybody be able to show me how to do this, as ive never done it before? thanks.. Quote Link to comment Share on other sites More sharing options...
dbo Posted November 15, 2007 Share Posted November 15, 2007 Or string replace / for - ? Quote Link to comment Share on other sites More sharing options...
effigy Posted November 15, 2007 Share Posted November 15, 2007 echo implode('-', array_reverse(explode('/', 'dd/mm/yyyy'))); Quote Link to comment Share on other sites More sharing options...
dbo Posted November 15, 2007 Share Posted November 15, 2007 Hahaha, that's wrong on so many levels! But it should work Quote Link to comment Share on other sites More sharing options...
dbo Posted November 15, 2007 Share Posted November 15, 2007 Oh, I didn't read very closely, string replace obviously doesn't work, sorry. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 15, 2007 Share Posted November 15, 2007 Here's another way to skin that cat. This will also ensure leading zeros are added to single digit months and days if not included in the input: <?php echo date('Y-m-d', strtotime("1/6/2007")); //Output 2007-01-06 ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.