$date_begin = date('Y-m-d H:i:s', mktime(0, 0, 0, date('m'), '01', date('Y'))); $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date('m')+1, '01', date('Y'))); $query = $db->query("SELECT SUM(`Hours`) FROM `data` WHERE `Name` LIKE 'vladlen' AND Date_user>='" . $date_begin . "' AND Date_user<'" . $date_end . "'");
function toCorrect($user_date) { $date = explode('-', $user_date); $correct_date = date('Y-m-d', mktime(0, 0, 0, $date[1], $date[0], $date[2])); return $correct_date; } $user_date = '06-12-16'; // то, что ввел пользователь print toCorrect($user_date); // 2016-12-06