- In your pubspec.yaml, add this dependencie package: intl:
- In your highest StatefulWidget (in your dart file), add these imports:
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
- In its State, override initState add :
@override
void initState() {
super.initState();
initializeDateFormatting(); //very important
}
- And the code:
DateTime now = new DateTime.now();
var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String nowFormatted = formatter.format(now);
Reference
https://stackoverflow.com/questions/36174033/intl-package-and-date-formatting-strange-behaviour
intl package and date formatting strange behaviour
I start to use intl package in my dart project. After start to use this package i use this code: DateTime now = new DateTime.now(); var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
stackoverflow.com
728x90
'Flutter' 카테고리의 다른 글
[Flutter] flutter listtile remove padding (0) | 2023.01.10 |
---|---|
[Flutter] 리스트와 매칭되는 bool 리스트 만들기 (0) | 2022.12.22 |
[iOS] 앱 이전 (0) | 2022.11.18 |
[Flutter / iOS] 'No such module' 에러로 archive build failed (0) | 2022.08.31 |
AI농장모니터링 Lite 개인정보처리방침 (0) | 2022.08.31 |