开发者

Timestamp to internal day count

开发者 https://www.devze.com 2022-12-14 07:34 出处:网络
On one project, I have an internal calculation of times. The days since the launch are simply enumerated:

On one project, I have an internal calculation of times.

The days since the launch are simply enumerated:

2009/10/19: launch day 2009/10/20: day 1 2009/10/21: day 2 etc.

Now I would like to have a function which gives me the current day of the internal calculation of times. E.g. "day 129" on one day in 2010.

But it is important to have this accuracy:

2009/10/20 00:00:01 => day 1 2009/10/20 23:59:59 => day 1 2009/10/21 00:00:01 => day 2

I built the following function but it doesn't have that accuracy. Why not? Can you improve it?

function date2daycount($timestamp) {
 $launchDay = 1255903200-3600*24;开发者_开发问答 // launch (2009/10/19 00:00:00)
 $difference = floor(($timestamp-$launchDay)/86400); // days after launch
 return $difference;
}

Thanks in advance!


function date2daycount($timestamp) {
 $launchDay =  strtotime('19 October 2009'); // launch (2009/10/19 00:00:00)
 $difference = floor(($timestamp-$launchDay)/86400); // days after launch
 return $difference+1;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消