C#-如何计算当前年份? [英] C# - How to calculate the current day-of-year?
本文介绍了C#-如何计算当前年份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天是 5.27.2010
-这意味着它是今年的147天。
Today is 5.27.2010
- this means it is day 147 of this year.
我该如何计算当前日期为今天的147?
How do I calculate that today is 147 based on the current date?
推荐答案
有一个 DateTime
属性命名为: DayOfYear
Console.WriteLine(DateTime.Now.DayOfYear);
或对于任何日期:
var d = new DateTime(2010, 5, 30);
Console.WriteLine(d.DayOfYear);
这篇关于C#-如何计算当前年份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文