gopinath
gopinath

Reputation: 99

How to get particular month starting date of current year in flutter

how to get current year starting date or particular month starting date programmatically in flutter

Upvotes: 0

Views: 1357

Answers (2)

Chirag Mevada
Chirag Mevada

Reputation: 317

You can find first month with the first day (1st January) of the current year easily by doing this

DateTime(DateTime.now().year) //specify only current year

by doing this you will get a date as

2022-01-01 00:00:00.000

Upvotes: 1

Derrick Zziwa
Derrick Zziwa

Reputation: 13

import 'package:intl/intl.dart';

main() {
  static final DateTime now = DateTime.now();
  static final DateFormat formatter = DateFormat('yyyy-MM-dd');
  final String formatted = formatter.format(now);
  print(formatted); // something like 2022-04-20
}

Upvotes: 0

Related Questions