【问题标题】:Format the date with day and month用日期和月份格式化日期
【发布时间】:2020-10-18 04:10:22
【问题描述】:

我将如何格式化返回的日期以显示日期和月份,例如 23 AUG 与我的代码。

 var finaldate;

  void callDatePicker() async {
    var order = await getDate();
    setState(() {
      finaldate = order;
    });
  }

  Future<DateTime> getDate() {
    return showDatePicker(
      context: context,
      initialDate: DateTime.now(),
      firstDate: DateTime(2020),
      lastDate: DateTime(2025),
Text('$finaldate',

【问题讨论】:

标签: date flutter datepicker format


【解决方案1】:

您可以使用intl 包中的DateFormat

DateFormat('dd MMM, yyyy').format(finaldate) // gives 27 Jun, 2020

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    • 1970-01-01
    • 1970-01-01
    • 2011-05-23
    相关资源
    最近更新 更多