基于移动设备设置的Flutter显示DateTime [英] Flutter display DateTime based on mobile device settings

查看:63
本文介绍了基于移动设备设置的Flutter显示DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关使用抖动以及从数据库中获取UTC日期时间并根据移动设备设置(例如区域设置,24小时制与12小时制等)显示该时间的指南.

I am looking for some guidance on using flutter and taking a UTC datetime from the DB and displaying that time based on mobile devices settings like locale, 24 versus 12 hour time, etc...

我已经完成了日期格式化,没有任何问题,只是希望以此为指导.

I have done dateformating in flutter without an issue, just hoping for some guidance to do it in this manner.

谢谢

推荐答案

我发现,如果要显示从数据库中提取的UTC,只需使用DateTime.toLocal()

I have found that if its for display of a UTC pulled from DB just use the DateTime.toLocal()

然后,您可以在日期时间对其他项目进行格式化.

Then you can do the formatting on the datetime for other items.

这篇关于基于移动设备设置的Flutter显示DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆