W3cubDocs

/Dart 2

isAfter method

bool isAfter (DateTime other)

Returns true if this occurs after other.

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

var now = new DateTime.now();
var later = now.add(const Duration(seconds: 5));
assert(later.isAfter(now));
assert(!now.isBefore(now));

// This relation stays the same, even when changing timezones.
assert(later.isAfter(now.toUtc()));
assert(later.toUtc().isAfter(now));

assert(!now.toUtc().isBefore(now));
assert(!now.isBefore(now.toUtc()));

Implementation

bool isAfter(DateTime other) {
  return _value > other._value;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-core/DateTime/isAfter.html