我怎样才能在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.