且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何计算两个给定日期之间的天数? (闰年障碍)

更新时间:2022-01-23 23:15:33

转换他们两个UNIX纪元时间,减去的差异。

Convert them both to UNIX epoch time and subtract the difference.

UNIX的历元时间是几秒钟的自1的日期的总数1970年1月00:00:00.0

UNIX Epoch time is the total number of seconds for a date since 1 January 1970 00:00:00.0

一旦你得到了多少秒,你把这种差异通过的秒数一天(即 24小时*60分钟* 60秒=86400秒的)。

Once you've got the number of seconds, you divide that difference by the number of seconds in a day (which is 24 hours * 60 minutes * 60 seconds = 86400 seconds).