/** * Create a \DateTime from a date picker form input * The date format is the same as the one from the current User Session * Ex : $lang = $session->getLang() * * @param Lang $lang Object containing date format * @param string $date String to convert * * @return \DateTime */ public function getDateTimeFromForm(Lang $lang, $date) { $currentDateFormat = $lang->getDateFormat(); return \DateTime::createFromFormat($currentDateFormat, $date); }