flutter date format 1

flutter date format

import 'package:intl/intl.dart';

DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd – kk:mm').format(now);

Here is what the above code is Doing:
1. We import the intl package.
2. We create a DateTime object called now.
3. We create a String object called formattedDate.
4. We use the DateFormat class to format the date and time.
5. We use the format() method to format the date and time.
6. We pass the now object to the format() method.

Similar Posts