Date Time format in Flutter dd/MM/YYYY hh:mm

前端 未结 6 1070
耶瑟儿~
耶瑟儿~ 2020-12-28 14:10

By using this :

Text(new DateTime.fromMillisecondsSinceEpoch(values[index][\"start_time\"]*1000).toString(), 

I am getting the ty

6条回答
  •  有刺的猬
    2020-12-28 15:02

    Use intl package:

    import 'package:intl/intl.dart';
    

    And then:

    var inputFormat = DateFormat('dd/MM/yyyy HH:mm');
    var inputDate = inputFormat.parse('31/12/2000 23:59'); // <-- Incoming date
    
    var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
    var outputDate = outputFormat.format(inputDate); // <-- Desired date
    print(outputDate); // 12/31/2000 11:59 PM
    

提交回复
热议问题