timeofday format flutter code example
Example 1: flutter datetime format
import 'package:intl/intl.dart';
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd – kk:mm').format(now);
Example 2: string to timeofday flutter
TimeOfDay _startTime = TimeOfDay(hour:int.parse(s.split(":")[0]),minute: int.parse(s.split(":")[1]));
Example 3: how to format timeofday in custom format flutter
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
builder: (context, _) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
alwaysUse24HourFormat: true),
child: _);
});