DateTime 및 Duration
void main() {
print('-------------------------');
DateTime now = DateTime.now();
print(now);
print(now.year);
print(now.month);
print(now.day);
print(now.hour);
print(now.minute);
print(now.second);
print(now.millisecond);
print('-------------------------');
Duration duration = Duration(seconds: 60);
print(duration);
print(duration.inDays);
print(duration.inHours);
print(duration.inMinutes);
print(duration.inSeconds);
print(duration.inMicroseconds);
print('-------------------------');
DateTime specificDay = DateTime(
2022,
10,
13
);
print(specificDay);
final difference = now.difference(specificDay);
print(difference);
print(difference.inDays);
print('-------------------------');
print(now.isAfter(specificDay));
print(now.isBefore(specificDay));
print(now);
print(now.add(Duration(hours: 10)));
print(now.subtract(Duration(seconds: 20)));
}
Last updated