Friday, August 26, 2022

Get Month name and Week name in Dart Flutter

 import 'package:intl/intl.dart';


void main() {

  print(DateTime.now().month); // get current month number

  print(DateTime.november); // get given month number

 

  DateTime date = DateTime.now();

  print(DateFormat('MMMM').format(date)); // get current month name

  print(DateFormat('EEEE').format(date)); // get current week name

}


// below url has the supported set of skeletons, e.g., 'MMMM', 'EEEE'

// https://api.flutter.dev/flutter/intl/DateFormat-class.html#:~:text=constructor%20is%20preferred.-,ICU,-Name%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Skeleton%0A%20%2D%2D%2D%2D%2D%2D%2D%2D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2D%2D%2D%2D%2D%2D%2D%2D%0A%20DAY


No comments:

Post a Comment