Home:ALL Converter>Strict comparison of DateTime Objects

Strict comparison of DateTime Objects

Ask Time:2017-04-24T23:38:04         Author:LBA

Json Formatter

I am doing a strict comparison on a list of objects, just to identify objects which might have changed, like:

if ($oldValue !== $newValue)

in some cases $oldValue and $newValue are DateTime objects.

Debugging my app I am getting the following output for my two values just before comparing them:

DateTime Object ( [date] => 2017-04-24 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC )

DateTime Object ( [date] => 2017-04-24 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC )

Why is my comparison/condition still true?

Author:LBA,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43592329/strict-comparison-of-datetime-objects
yy