[英]How to Convert date in string type to another date format. | Flutter | Dart
I have a string date and I want to convert it in another format.我有一个字符串日期,我想将其转换为另一种格式。 For eg: I have a date
"25/04/2020"
as string and I want to convert this to the string as "25 Apr 2020"
like this.例如:我有一个日期
"25/04/2020"
作为字符串,我想像这样将它转换为字符串"25 Apr 2020"
。 "10/02/2020"
become "10 Feb 2020",
"27/11/2021"
become "27 Nov 2021"
, like this. "10/02/2020"
变成"10 Feb 2020",
"27/11/2021"
变成"27 Nov 2021"
,像这样。
Use package intl
使用
intl
import 'package:intl/intl.dart';
void main() {
var dateString = "25/04/2020";
var dateTime = DateFormat('dd/MM/yyyy').parse(dateString);
print(DateFormat('dd MMM yyyy').format(dateTime));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.