What version of PHP are you running in? According to PHP , createDateFormat
is available in versions> = 5.3.0.
- Change
It looks like your code misused DateTime, since createFromFormat returns an object, not a string, but you have to transfer DateTime :: createFromFormat () calls from date ().
// PHP >= 5.3.0 $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']); // PHP < 5.3.0 $datetime_lower = date('d/m/Y', $min); $datetime_upper = date('d/m/Y', $max); $datetime_compare = date('d/m/Y g:i a', $row_update['pDate']);
It seems to me that if you are dealing with timestamps, you can make ops comparisons without having to convert to a specific format. If one of the dates you are working with is not in the timestamp format, you can do the following:
$timestamp = strtotime($yourFormattedDateTime);
Mike purcell
source share