我如何从字符串日期中获取日名' 2022年5月22日'在颤抖中

发布于 2025-01-28 11:58:35 字数 208 浏览 3 评论 0 原文

我是Flutter的初学者,我想获得日名 [像星期日] 从日期开始,我从API获得的日期,基本上是 '22 2022年5月22日的字符串'

如何从此日期开始 '22 2022'?谁能帮我吗?任何帮助都应该不胜感激

,我已经尝试过,但对我不起作用。

态Dart的一周

I am a beginner in Flutter, I want to get day name [like Sunday] from a date, date i am getting from api which is basically a string like '22 May 2022'

How can i get that from this date '22 May 2022' ? Can anyone help me? any help should be appreciated

I have tried this but not working for me.

How get the name of the days of the week in Dart

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

堇色安年 2025-02-04 11:58:35

尝试以下操作:

final dateName = DateFormat('EEEE').format(DateFormat("DD MMMM yyyy").parse('22 May 2022'));

Try this :

final dateName = DateFormat('EEEE').format(DateFormat("DD MMMM yyyy").parse('22 May 2022'));
寒冷纷飞旳雪 2025-02-04 11:58:35

您可以使用它:

 导入'软件包:intl/intl.dart';

// ------------------------------

最终的日期时间= dateTime.now();

最终dateformat格式= dateFormat('eee');
最终dateformat格式2 = dateformat('eeee');

print(format1.format(tody)); //缩写,经验。 :太阳,星期一,星期二,...
print(format2.format(tody)); //不缩写,经验。 :suday,星期一,...
 

You can use it:

import 'package:intl/intl.dart';

//--------------------

final DateTime today = DateTime.now();

final DateFormat format1 = DateFormat('EEE');
final DateFormat format2 = DateFormat('EEEE');

print(format1.format(today)); // abbreviated, exp. : Sun, Mon, Tue, ...
print(format2.format(today)); // not abbreviated, exp. : Suday, Monday,...
记忆之渊 2025-02-04 11:58:35

final datename = dateformat('med')。格式(dateformat(“ dd mmmm yyyy”)。parse('22 5月22日2022'));

您可以检查所有格式日期

final dateName = DateFormat('MEd').format(DateFormat("DD MMMM yyyy").parse('22 May 2022'));

You can check there all format date
https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html

简单 2025-02-04 11:58:35
String daysOfTheWeek = DateFormat('EEEE').format(DateTime.now());

// 星期日

String daysOfTheWeek = DateFormat('EEEE').format(DateTime.now());

// Sunday

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文