Timestamp to internal day count
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;
}
精彩评论