반응형

DateTime  now = DateTime.now();

Duration duration = const Duration(seconds: 600); //600

설명 구현 샘플
현재날짜 now 2023-11-06 12:03:40.556
현재연도, 월 등 now.year
now.month
now.day
now.hour
2023
11
06
11
특정 날짜 지정 DateTime sday = DateTime(2023, 11, 06); 2023-11-06 00:00:00.000
Duration 환산 duration.inDays
duration.inHours
duration.inMinutes

0
10
두개의 날짜 비교 final diff = now.difference(sday); 

diff
diff.inDays
diff.inHours
diff.inMinutes

12:03:40.556000
0
12
723
날짜 + now.add(
  Duration(hours: 10),
);
2023-11-06 22:03:40.556

날짜 - now.subtract(
  Duration(hours: 10),
);
2023-11-06 02:03:40.556

 

반응형

'IT > Flutter' 카테고리의 다른 글

[IDE] Android Studio 단축키  (0) 2023.11.02
[Dart] 기본문법 - 변수  (0) 2023.04.05

+ Recent posts