简体   繁体   中英

What was the date 180 days ago?

我怎样才能在180天前使用C#获取日期?

DateTime oneEightyAgo = DateTime.Today.AddDays(-180);

EDIT:

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

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

DateTime oneEightyAgo = DateTime.Now.ToUniversalTime().AddDays(-180); 

最好记录UTC ...

DateTime.Now.AddDays(-180)

DateTime.Now.AddDays(-180)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM