简体   繁体   中英

get number of weeks away from today

我将来有个约会,我想知道这有几周的路程。

(futureDate - DateTime.Today).TotalDays / 7

I think you'd be best getting the no of days and dividing that by 7

DateTime start = DateTime.Now;
DateTime end = DateTime.Now.AddDays(21);

double noOfDays = (end - start).TotalDays;
double noOfWeeks = noOfDays  / 7;

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