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 trial

PHP CRUD Operations with PHP Reading and Writing Reports Working with Dates

CRUD operations with php

When saving a date in a 'date' field, you need make sure the date is formatted properly. The correct format is YYYY-MM-DD.

Complete the function to convert a passed date into a SQL safe date and return the results using the following requirements: -Use the date() function to properly format the passed date. -Use the strtotime() function to accept anything from a date in a different format to a string like 'yesterday'.

need help with that challenge guys, i have been stuck for a while now.

index.php
<?php

function convert_date_sql($date) {
    //add your code here  

}
Chris Shaw
Chris Shaw
26,676 Points

Hi Delroy,

What have you tried so far? Could you please post any code you have so we can walk through it with you.

https://teamtreehouse.com/forum/posting-code-to-the-forum

return date("Y-m-d", strtotime($date));