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

前端 未结 7 1594
攒了一身酷
攒了一身酷 2020-12-05 12:33

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

7条回答
  •  猫巷女王i
    2020-12-05 13:31

    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);
    

提交回复
热议问题