isBefore method
- 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.
var now = DateTime.now(); var earlier = now.subtract(const Duration(seconds: 5)); assert(earlier.isBefore(now)); assert(!now.isBefore(now)); // This relation stays the same, even when changing timezones. assert(earlier.isBefore(now.toUtc())); assert(earlier.toUtc().isBefore(now)); assert(!now.toUtc().isBefore(now)); assert(!now.isBefore(now.toUtc()));
Implementation
external bool isBefore(DateTime other);
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/DateTime/isBefore.html