dart datetime difference
//the birthday's date
final birthday = DateTime(1967, 10, 12);
final date2 = DateTime.now();
final difference = date2.difference(birthday).inDays;
dart datetime difference
//the birthday's date
final birthday = DateTime(1967, 10, 12);
final date2 = DateTime.now();
final difference = date2.difference(birthday).inDays;
fluter check that date is greater than another date
var now = new DateTime.now();
var berlinWallFellDate = new DateTime.utc(1989, 11, 9);
// 0 denotes being equal positive value greater and negative value being less
if(berlinWallFellDate.compareTo(now)>0)
{
//peform logic here.....
}
compare date month and year in datetime in flutter
Since I asked this, extension methods have been released in Dart. I would now
implement option 1 as an extension method:
extension DateOnlyCompare on DateTime {
bool isSameDate(DateTime other) {
return this.year == other.year && this.month == other.month
&& this.day == other.day;
}
}
About Extensions :
https://dart.dev/guides/language/extension-methods
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us