isBefore method

bool isBefore(
  1. DateTime other

Returns true if this occurs before other.

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

final now =;
final earlier = now.subtract(const Duration(seconds: 5));
print(earlier.isBefore(now)); // true
print(!now.isBefore(now)); // true

// This relation stays the same, even when changing timezones.
print(earlier.isBefore(now.toUtc())); // true
print(earlier.toUtc().isBefore(now)); // true

print(!now.toUtc().isBefore(now)); // true
print(!now.isBefore(now.toUtc())); // true


external bool isBefore(DateTime other);