0

here is the code which i already formatted it to be [yyyy-MM-dd] but it also contains 00:00:00 :


    child: Text(
         _selectedDate == null
     ? 'No Date Choosen!'
     : '${DateFormat('yyyy-MM-dd').format(_selectedDate)}',
     style: TextStyle(
     color: Colors.white, fontSize: 16),),

Ahmad Mohy
  • 331
  • 1
  • 3
  • 10
  • Related: https://stackoverflow.com/questions/55702224, https://stackoverflow.com/questions/58337796 – kvantour Jul 08 '20 at 11:12

2 Answers2

0

You need to create a new DateFormat object.

final df = new DateFormat('yyyy-MM-dd');
Text(_selectedDate == null ? 'No Date Choosen!' : '${df.format(_selectedDate)}');
mekamade
  • 46
  • 4
0

Here is an example of how formatting a date:

  final DateTime now = DateTime.now();
  final DateFormat formatter = DateFormat('yyyy-MM-dd');
  final String formatted = formatter.format(now);
  print(formatted);
P4yam
  • 2,107
  • 2
  • 12
  • 22