What was the date 180 days ago?

后端 未结 5 1599
遇见更好的自我
遇见更好的自我 2021-02-18 13:55

How would I get the date 180 days ago using C#?

相关标签:
5条回答
  • 2021-02-18 14:00

    DateTime.Now.AddDays(-180)

    0 讨论(0)
  • 2021-02-18 14:07

    EDIT:

    DateTime day180 = Date.Now.AddDays(-180);
    

    It's important to put it into a separate variable otherwise the value will be lost.

    0 讨论(0)
  • 2021-02-18 14:16
    DateTime oneEightyAgo = DateTime.Today.AddDays(-180);
    
    0 讨论(0)
  • 2021-02-18 14:20

    DateTime.Now.AddDays(-180)

    0 讨论(0)
  • 2021-02-18 14:22
    DateTime oneEightyAgo = DateTime.Now.ToUniversalTime().AddDays(-180); 
    

    Its best to record UTC...

    0 讨论(0)
提交回复
热议问题