PHP:分钟至年月日时分 [英] PHP: Minutes to year month day hour minute

查看:236
本文介绍了PHP:分钟至年月日时分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基于文本的PHP游戏.每秒都有一次更新,并且更新后,从数据库中选择行time,其中包含例如548991.这意味着548991分钟已经过去了,因此这意味着例如它的第一年,第一个月,第四天,第七小时和第51分钟.我如何计算得出,以便使数字548991使用PHP代码成为 Year 1,Year 1,Month 1,Day 4,07:51 AM ?

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?

推荐答案

不回答这个问题就花费了很多额外的精力.另外,Thew,我知道您没有放弃,因此在找到解决方案时回答自己的问题对您的业力很有帮助.

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...

和平

这篇关于PHP:分钟至年月日时分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆