DekGenius.com
DART
flutter datetime to string
dependencies:
intl: ^0.17.0
import 'package:intl/intl.dart';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
String string = dateFormat.format(DateTime.now()); //Converting DateTime object to String
DateTime dateTime = dateFormat.parse("2019-07-19 8:40:23"); //Converting String to DateTime object
dart convert string to datetime
var dateTime = DateTime.parse("dateTimeString");
Flutter String to dateTime format
DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(savedDateString);
string to datetime flutter
import 'package:intl/intl.dart';
...
var dmyString = '23/4/1999';
var dateTime1 = DateFormat('d/M/y').parse(dmyString);
var mdyString = '04/23/99';
var dateTime2 = DateFormat('MM/dd/yy').parse(mdyString);
var mdyFullString = 'April 23, 1999';
var dateTime3 = DateFormat('MMMM d, y', 'en_US').parse(mdyFullString));
flutter string to date time
DateTime.parse("string date here");
convert date in flutter
import 'package:intl/intl.dart';
String? convertiEnDateEtHeure(n) {
String date = DateFormat.yMMMd().add_Hm().format(n);
return date;
}
convert timeofday to string flutter
String formatTimeOfDay(TimeOfDay tod) {
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, tod.hour, tod.minute);
final format = DateFormat.jm(); //"6:00 AM"
return format.format(dt);
}
string to timeofday flutter
TimeOfDay _startTime = TimeOfDay(hour:int.parse(s.split(":")[0]),minute: int.parse(s.split(":")[1]));
flutter timestamp to datetime
Timestamp t = document['timeFieldName'];
DateTime d = t.toDate();
print(d.toString()); //2019-12-28 18:48:48.364
flutter timestamp to datetime
DateFormat.yMMMd().add_jm().format(myDateTime);
flutter timestamp to datetime
Map<String, dynamic> map = docSnapshot.data()!;
DateTime dt = (map['timestamp'] as Timestamp).toDate();
© 2022 Copyright:
DekGenius.com