I have a problem with Dart intl package while using DateFormat
formatDateTime(DateFormat("yyyy-MM-dd hh:mm").parse(fortune.readFinishedAt ?? "2025-12-27 12:27:45")), When I use this code, I want to take 12:27 for hour part but DateFormat gives 00:27 to me. hour property is 0,
How can I solve this bug?
CodePudding user response:
use formate like I mention below:-
formatDateTime(DateFormat("yyyy-MM-dd hh:mm a").parse(fortune.readFinishedAt ?? "2025-12-27 12:27:45")),
use hh:mm a it will gave you time in am/pm formate
CodePudding user response:
It seems like you want to use 12 hr time period
use formate like I mention below:- if yopu want to use 12 hr time use (hh:mm) a insted of (hh:mm)it will gave you time in am/pm formate
formatDateTime(DateFormat("yyyy-MM-dd hh:mm a").parse(fortune.readFinishedAt ?? "2025-12-27 12:27:45"))
CodePudding user response:
If you need to the 24 hour format use this DateFormat("yyyy-MM-dd HH:mm")
.
CodePudding user response:
Use this,
formatDateTime(DateFormat("yyyy-MM-dd h:mm:ss a").parse(fortune.readFinishedAt ?? "2025-12-27 12:27:45")),
For more info : https://api.flutter.dev/flutter/intl/DateFormat-class.html