bool isAtSameMomentAs(
DateTime other
)

Returns true if this occurs at the same moment as other.

The comparison is independent of whether the time is in UTC or in the local time zone.

DateTime berlinWallFell = new DateTime(1989, 11, 9);
DateTime moonLanding    = DateTime.parse("1969-07-20 20:18:00");

assert(berlinWallFell.isAtSameMomentAs(moonLanding) == false);

Source

/**
 * Returns true if [this] occurs at the same moment as [other].
 *
 * The comparison is independent of whether the time is in UTC or in the local
 * time zone.
 *
 *     DateTime berlinWallFell = new DateTime(1989, 11, 9);
 *     DateTime moonLanding    = DateTime.parse("1969-07-20 20:18:00");
 *
 *     assert(berlinWallFell.isAtSameMomentAs(moonLanding) == false);
 */
bool isAtSameMomentAs(DateTime other) {
  return millisecondsSinceEpoch == other.millisecondsSinceEpoch;
}