How to change date and time format in flutter?

后端 未结 1 1060
我在风中等你
我在风中等你 2021-01-25 03:30

how are you ?

my backend just accept date and time in this format 2019-03-24 11:00:00

and i use in my app calendar widget to get the date and it print the date

相关标签:
1条回答
  • 2021-01-25 03:53

    You can use intl package

    Here is an example:

    import 'package:intl/intl.dart';
    
    main() {
      var now = new DateTime.now();
      var dateFormat = new DateFormat('yyyy-MM-dd HH:mm:ss');
      String formattedDate = dateFormat.format(now);
      print(formattedDate); // 2019-04-28 09:02:29
    }
    
    0 讨论(0)
提交回复
热议问题