PHP: Minutes to year month day hour minute

2019-09-01 16:24发布

I'm making a text based PHP game. Every second there is an update, and update, the row time gets selected from the database, containing for example 548991. That means 548991 minutes have gone by, so that means that for example its the first year, the first month, the 4th day, the 7th hour and the 51th minute. How can i calculate that, so that the number 548991 results into: Year 1, Month 1, Day 4, 07:51 AM using PHP code?

标签: php math time
1条回答
ゆ 、 Hurt°
2楼-- · 2019-09-01 16:52

Alot of extra effort is spent not answering this question. Also, Thew, I know you didn't give up, so answering your own question when you find a solution would have been good for your Karma.

My grandfather once told me you catch more flies with honey. I get what these guys are saying, but I just think we should all treat each other a little better.

Answering with some tags...

Answering with some code...

$datetime1 = new DateTime('now - {$minutes}minutes');
$datetime2 = new DateTime('now');
$interval = date_diff($datetime2,$datetime1);
echo $interval->format('%r Year %y, Month %m, Day %d, %H:%I %a');

Answering removes this question from the unanswered list...

Peace

查看更多
登录 后发表回答