I\'m looking for a function identical to DateTime::createFromFormat but I need it to work in an environment running a version of PHP which is older than v5.3. Basically I ne
You may use strptime() - it's using strftime() format. A bit different compared to date() format but does almost the same things.
function createFromFormat($strptimeFormat, $date) {
$date = strptime($date, $strptimeFormat);
$date['tm_year'] += 1900;
$date['tm_mon']++;
$timestamp = mktime($date['tm_hour'], $date['tm_min'], $date['tm_sec'], $date['tm_mon'], $date['tm_mday'], $date['tm_year']);
return new DateTime('@'. $timestamp);
}