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

前端 未结 6 1069
耶瑟儿~
耶瑟儿~ 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 14:47

    You can use date_format plugin available here https://pub.dartlang.org/packages/date_format

    Then to convert,

    formatDate(DateTime.now(), [dd, '/', mm, '/', yyyy, ' ', HH, ':', nn])
    
    0 讨论(0)
  • 2020-12-28 14:47
    var dateInFormatText = widget.snapshot["date"].toString().split("/");
    
    DateTime dateResult = new DateTime.utc(
    int.parse(dateInFormatText[2]),     
    int.parse(dateInFormatText[1]), 
    int.parse(dateInFormatText[0]));
    
    
    0 讨论(0)
  • 2020-12-28 14:49

    If you use the intl package

    final f = new DateFormat('yyyy-MM-dd hh:mm');
    
    Text(f.format(new DateTime.fromMillisecondsSinceEpoch(values[index]["start_time"]*1000)));
    
    0 讨论(0)
  • 2020-12-28 14:50

    If you use the intl package:

    var date = DateTime.fromMicrosecondsSinceEpoch(miliseconds * 1000)
    DateFormat(DateFormat.YEAR_MONTH_DAY, 'pt_Br').format(date.toUtc())
    

    Output: 10 de abril de 2020

    0 讨论(0)
  • 2020-12-28 14:55

    First install the pub.dev/packages/intl package in your pubspec.yaml

       intl: ^0.16.1
    

    Then use

       final df = new DateFormat('dd-MM-yyyy hh:mm a');
       int myvalue = 1558432747;
       print(df.format(new DateTime.fromMillisecondsSinceEpoch(myvalue*1000)));
    

    Output

    21-05-2019 10:59 AM

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题