Created
April 16, 2025 07:52
-
-
Save makmac213/be48b84c460745a4a26fe951741b54d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will check if the device is using 24-hour or 12-hour time settings. | |
// Experienced an error where client is in a different region and they can not | |
// select a time. It turns out we have different time format. | |
bool is24HourFormat = MediaQuery.of(context).alwaysUse24HourFormat; | |
String timeString = value.format(context); | |
if (is24HourFormat) { | |
reportTimeController.text = timeString; | |
} else { | |
DateTime timeDateTime = DateFormat("hh:mm a").parse(timeString); | |
reportTimeController.text = DateFormat("HH:mm").format(timeDateTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment