gpt4 book ai didi

flutter - 如何在 Dart 中获取星期几的名称

转载 作者:IT老高 更新时间:2023-10-28 12:38:47 28 4
gpt4 key购买 nike

有人知道如何从 DateTime 中提取星期几的名称吗?

ej:

DateTime date = DateTime.now();
String dateFormat = DateFormat('dd-MM-yyyy hh:mm').format(date);

结果 -> 星期五

最佳答案

使用“EEEE”作为日期模式

 DateFormat('EEEE').format(date); /// e.g Thursday

别忘了导入

import 'package:intl/intl.dart';

查看更多信息:https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html

关于flutter - 如何在 Dart 中获取星期几的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54371874/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com