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 trialBenoit Tordeurs
Full Stack JavaScript Techdegree Student 9,400 Pointshttps://teamtreehouse.com/library/crud-operations-with-php/reading-and-writing-reports/working-with-dates, crud operatio
I can't find any solution to this Challenge even in MDN: "SO please, Help"?
<?php
function convert_date_sql($date) {
$date = strtotime($date);
$date = date("yyyy-mm-dd",$date);
return $date;
} ?>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there, Benoit Tordeurs ! Actually, you're not far off on this one. But part of the problem is that you're overwriting the $date variable that is sent in. Also, you're trying to use the format they gave as an example as the arguments for the date
function which isn't exactly correct.
I chose to return the results directly without creating new variables as it feels cleaner and more concise to me. But this is my opinion.
function convert_date_sql($date) {
//add your code here
return date('Y-m-d', strtotime($date));
}
It's just one line of code but it says essentially this: "Return the date with the year first, month second and day last. Separate these with a hyphen. Parse any English version of time like "tomorrow" or "yesterday" to a UNIX timestamp."
You say that you didn't find any answers in the MDN documentation. But this is not surprising at all. MDN (Mozilla Developer Network) contains documentation about Open Web technologies such as HTML, CSS, and JavaScript. You will not find PHP documentation on MDN. Instead, you should be using the PHP documentation at php.net
To make this perfectly clear, PHP and JavaScript are two entirely different languages. Just as both English and Swedish are Germanic based languages, PHP and JavaScript are both programming languages, but they are both unique just as English and Swedish are distinct languages.
Hope this helps!
Benoit Tordeurs
Full Stack JavaScript Techdegree Student 9,400 PointsAMAZING !!!!!!!!! Whaowwww, I was looking for a solution for so long !!!!! Thank you Jennifer!