Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRonaldo Fialho
5,105 PointsConverting date
<?php
function convert_date_sql($date) { //add your code here $results = date('Y/m/d', strtotime($date)); return $results; } echo convert_date_sql("yesterday");
Need help, guys!! it seems to me is converting to the right format. What can possible be wrong? it says i'm not returning the right date.
<?php
function convert_date_sql($date) {
//add your code here
$results = date('Y/m/d', strtotime($date));
return $results;
}
echo convert_date_sql("yesterday");
1 Answer
Michael Collins
3,447 PointsHi Ronaldo,
They are asking for the date format of YYYY-MM-DD.
So what you have done is correct, except you have used forward slashes rather than hyphens. It should be:
<?php
function convert_date_sql($date) {
//add your code here
$results = date('Y-m-d', strtotime($date));
return $results;
}
echo convert_date_sql("yesterday");
?>
Ronaldo Fialho
5,105 PointsRonaldo Fialho
5,105 PointsGreat!! Thx Michael!!! you're right!!!
Michael Collins
3,447 PointsMichael Collins
3,447 PointsNo problem! :)