Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
model.hwPublishedDate
.toDate()
.hour
.toString() +
":" +
model.hwPublishedDate
.toDate()
.minute
.toString() +
" " +
model.hwPublishedDate
.toDate()
.timeZoneName
.toString() +
", " +
model.hwDate,
style: GoogleFonts.abel(
color: Colors.green[500],
fontSize: 15.0,
fontWeight: FontWeight.bold),
),
),
),
)
],
),
),
ListTile(
leading: Icon(
Icons.calendar_today_sharp,
color: Colors.green[900],
),
title: DateTimeField(
validator: (value) =>
value == null ? 'Provide Upload Date' : null,
showCursor: true,
cursorColor: Colors.green,
textCapitalization: TextCapitalization.words,
style: TextStyle(color: Colors.green[900]),
controller: _hwdateTextEditingController,
decoration: InputDecoration(
hintText: "Date",
hintStyle: TextStyle(
color: Colors.green[900],
),
border: InputBorder.none),
format: DateFormat("dd-MM-yyyy"),
onShowPicker: (context, currentValue) {
return showDatePicker(
context: context,
firstDate: DateTime(1947),
initialDate: currentValue ?? DateTime.now(),
lastDate: DateTime(2100));
},
onChanged: (selectedCateg) {
setState(() {
queryString = selectedCateg.toString();
classSec = selectedClass + selectedSec;
});
startSearching(classSec);
},
),
),
You first go with .toDate().toString() and then format it using Date Format, and the Listile is how I store Date if you want you can use it that way too