开发者

PHP Minutes in month

I need to be able to find the number of minutes passed i开发者_如何学Pythonn the current month so far. So from midnight of the first of the month until now.

How could I do this? So for example, 1AM on the first of the month would be give me 60 minutes.

Thanks


This should work for you:

$time = time();
$minutes = ($time-strtotime(date('Y-m-00', $time)))/60;

As of now $minutes === 15477.1


$seconds = time() - strtotime('2011-01-01 00:00:00');
$minutes = $seconds / 60;

To elaborate a bit more:

This is some simple manipulation of a unix timestamp (number of seconds since Jan 1, 1970). So you take the current timestamp and subtract what the timestamp would have been on the first of the month. This gives you total seconds that have elapsed this month. If you divide by 60, you get total minutes that have elapsed this month.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜