Php – Fatal error: Call to undefined method DateTime::createfromformat()

mysqlphp

How do you solve the error of:

Fatal error: Call to undefined method DateTime::createfromformat()

The error is happening at line 35. This is what my code reads from line 31 to 45

// check database for necessary updates

$update = mysql_query("SELECT * FROM rent WHERE colour='#3C0'");
while($row_update = mysql_fetch_array( $update )) {
    $datetime_lower   = DateTime::createFromFormat('d/m/Y', $min);
    $datetime_upper   = DateTime::createFromFormat('d/m/Y', $max);
    $datetime_compare = DateTime::createFromFormat('d/m/Y g:i a', $row_update['pDate']);
    if ($datetime_lower < $datetime_compare && $datetime_upper > $datetime_compare) {
        // date is between do nothing
    } else {
        // date is not between so update
        $update_result = mysql_query("UPDATE rent SET colour='#F0F0F0' WHERE id=" . $row_update['id'] . " && colour='#3C0'");
        mysql_close($update_result);
    }
}

How can I resolve this?

Best Solution

DateTime::createFromFormat() was introduced in php 5.3. And most likely you have older one. So - install php >= 5.3 and you'll get it worked.