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

please help my code is not getting through

please help my code is not getting through

index.php
<?php

function convert_date_sql($date) {
    //add your code here
  $dateMatch = explode('/',$date);
  var_dump ($dateMatch);
            if(empty($project_id) || empty($title) || empty(date) || empty($time)){
  $error_message = 'Please fill in the required fields: Project, titile, Date, Time';
  }elseif (count($dateMatch) !=3
          || strtotime($dateMatch[0]) ! = 2
          || strtotime($dateMatch[1]) ! = 2
           || strtotime ($dateMatch[4]) ! =4
           ||!checkdate($dateMatch[0],$dateMatch[1], $dateMatch)
          ){
    $error_message = 'Invalid Date';
  }
}

2 Answers

Hi, try this code instead.

<?php

function convert_date_sql($date) {
    //add your code here
    $newDate = date('Y-m-d', strtotime($date));
    return $newDate;

}

Martin thanks so much, it worked!!