all
In flutter dart,
I need chage "Oct 20, 2020 7:47:31 PM" to datetime,
what is time format of "Oct 20, 2020 7:47:31 PM".
Thanks.
all
In flutter dart,
I need chage "Oct 20, 2020 7:47:31 PM" to datetime,
what is time format of "Oct 20, 2020 7:47:31 PM".
Thanks.
You can try this DateFormat:
DateFormat dateFormat = DateFormat('MMM dd, yyyy h:mm:ss a');
You can use this package https://pub.dev/packages/intl
import 'package:intl/intl.dart';
class Sample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: Text(DateFormat('MMM dd, yyyy h:mm:ss a')
.format(DateTime.parse(DateTime.now().toString())))),
);
}
}
Try this one
DateTime dateTime = DateTime.now();
var finalDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(dateTime);