Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the current date (w/o hour and minutes)?

Tags:

flutter

dart

All I can see in the documentation is DateTime.now() but it returns the Timespan also, and I need just the date.

like image 819
user2070369 Avatar asked Jan 20 '16 21:01

user2070369


1 Answers

Create a new date from now with only the parts you need:

DateTime now = new DateTime.now(); DateTime date = new DateTime(now.year, now.month, now.day); 
like image 54
Günter Zöchbauer Avatar answered Sep 20 '22 10:09

Günter Zöchbauer