Difference between System.DateTime.Now and System.DateTime.Today

后端 未结 8 1135
悲哀的现实
悲哀的现实 2020-11-28 19:23

Can anyone explain the difference between System.DateTime.Now and System.DateTime.Today in C#.NET? Pros and cons of each if possible.

8条回答
  •  佛祖请我去吃肉
    2020-11-28 19:57

    Time. .Now includes the 09:23:12 or whatever; .Today is the date-part only (at 00:00:00 on that day).

    So use .Now if you want to include the time, and .Today if you just want the date!

    .Today is essentially the same as .Now.Date

提交回复
热议问题