为什么两个不同格式的日期时间在 Matlab 中不相等?

Why are two datetimes of different formats not equal in Matlab?

我是 运行 Matlab R2014b。我有两个日期时间变量,在我看来应该是等价的,是什么导致这里的逻辑等于 return FALSE?

testDate = textscan('20171231', '%{yyyymmdd}D')
myDate = testDate{1,1}
myDate == datetime(2017,12,31)

这个returns:

ans = 0

, you have to use 'MM' to correctly represent months instead of minutes in the call to textscan:

>> testDate = textscan('20171231', '%{yyyyMMdd}D');
>> myDate = testDate{1,1};
>> myDate == datetime(2017,12,31)

ans =

  logical

   1

有关 datetime 格式 属性 的更多信息,请参阅 here