获取自此以来的秒数
我正在用 C# 编写一个应用程序,我很想知道如何获取每个月的秒数。例如,今天,2 月 3 日,我很想知道:
January: 2678400
February: 264000
基本上,我很想知道过去几个月有多少秒以及当前月份有多少秒(到目前为止有多少秒)。
任何代码片段将不胜感激......
I am writing an application in C#, and I would love to know how you can get the number of seconds in each month. For example, today, February the 3th, I would love to have:
January: 2678400
February: 264000
Basically, I would love to know how many seconds in the past months and how many seconds in the current month at the current time (how many seconds so far).
Any code snippets would be appreciated....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从一个日期减去另一个日期总会得到差值的
TimeSpan
:Subtracting one date from another will always give you a
TimeSpan
of the difference:您可以将两个日期相减并得到它们之间的总秒数。
两个日期相减的结果是
TimeSpan
。You can subtract two dates from each other and get the total seconds between them.
The result of subtracting two dates from each other is a
TimeSpan
.您可以从
TimeSpan
获取TotalSeconds
属性:将为您提供本月到目前为止的秒数。
You can get the
TotalSeconds
property from aTimeSpan
:will give you the seconds so far this month.