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 Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/ 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 "-" Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392415 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.. Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392420 Share on other sites More sharing options...
dbo Posted November 15, 2007 Share Posted November 15, 2007 Or string replace / for - ? Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392423 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'))); Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392424 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 Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392427 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. Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392429 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 ?> Link to comment https://forums.phpfreaks.com/topic/77524-from-ddmmyyyy-to-yyyy-mm-dd/#findComment-392462 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.