jonsamwell Posted January 23, 2009 Share Posted January 23, 2009 Hi, I think i am doing this right but keep getting a weird return value. I'm changing a date format from d/m/y to y/m/d using the DATE() function, see below code. However the date i put in is not the date i get back out?? $start_date = '23/01/2009'; //input $start_date = date("Y-d-m", strtotime($start_date) ); //output = 2010-01-11 Can anyone see what i am doing wrong? Thanks Jon Link to comment https://forums.phpfreaks.com/topic/142098-date-conversion-error/ Share on other sites More sharing options...
gevans Posted January 23, 2009 Share Posted January 23, 2009 strtotime() doesn't like forward slashes, use this... <?php $start_date = '23/01/2009'; //input $start_date = str_replace('/', '-', $start_date); echo date("Y-d-m", strtotime($start_date) ); Link to comment https://forums.phpfreaks.com/topic/142098-date-conversion-error/#findComment-744186 Share on other sites More sharing options...
jonsamwell Posted January 23, 2009 Author Share Posted January 23, 2009 strtotime() doesn't like forward slashes, use this... <?php $start_date = '23/01/2009'; //input $start_date = str_replace('/', '-', $start_date); echo date("Y-d-m", strtotime($start_date) ); Thanks! Link to comment https://forums.phpfreaks.com/topic/142098-date-conversion-error/#findComment-744197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.