If you want to compare Exact datetime values (With Date)
This work is already done for you in the "==" operator.
nyTime = datetime(2017,1,1,0,0,0,'TimeZone','America/New_York')
tokyoTime = datetime(2017,1,1,14,0,0,'TimeZone','Asia/Tokyo')
isSame = nyTime == tokyoTime
Compare datetimes by Hour:Minute:Second across time zones (No Date)
If the datetime has defined the "TimeZone" property, the hours will change when you update the TimeZone. Using this, we can create a function that updates the TimeZone to 'UTC' and compares the "timeofday" value.
For example, to find the dates in
query = datetime('14:29:00', 'TimeZone', 'Asia/Tokyo');
You could create a function as follows to compare the values in a common timezone, here we use UTC:
function isSameHrMin = SameHourMinute(dtimes, query)
dtimes.TimeZone = 'UTC';
query.TimeZone = 'UTC';
isSameHrMin = timeofday(dtimes) == timeofday(query);
end
This function will return the indices of datetime values with the same timezone dependent hour, minute and second values.
Best Answer