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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Simbarashe Kazunga](https://secure.gravatar.com/avatar/8112dc24dc778cb19fe01667289532aa?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Simbarashe Kazunga
13,104 Pointsplease help my code is not getting through
please help my code is not getting through
<?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
![Martin Balon](https://uploads.teamtreehouse.com/production/profile-photos/1919402/micro_Untitledd.jpg)
Martin Balon
43,651 PointsHi, try this code instead.
<?php
function convert_date_sql($date) {
//add your code here
$newDate = date('Y-m-d', strtotime($date));
return $newDate;
}
![Simbarashe Kazunga](https://secure.gravatar.com/avatar/8112dc24dc778cb19fe01667289532aa?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Simbarashe Kazunga
13,104 PointsMartin thanks so much, it worked!!