Reputation: 99
how to get current year starting date or particular month starting date programmatically in flutter
Upvotes: 0
Views: 1357
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
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