我在 PHP 中有 2 次,我如何 运行 一个 foreach 循环来经历所有那些日子? (1 小时循环同一时间过去 24 小时!)
I have 2 time in PHP, how can I run a foreach loop to go through all of those days? (1 Hour loop same time Last 24 Hours!)
我从 now()
开始到 last 24 Hours
结束。我如何遍历 PHP 中的所有这些时间?
一次same time
一次和第二次loop
开始...
以下是您可能需要的此项目的 php 文档列表:
这里是 示例 代码,它将在一小时内给出最后 24 小时:
$timenow = time();
for ($i = 0; $i < 24; $i ++) {
$ago = strtotime("$i hours ago",$timenow);
echo $ago ," <-- ",strftime('%Y-%m-%d %H:%M:%S',$ago),"\n";
它使用相关格式中的这些格式:
number space? (unit | 'week')
Handles relative time items where the value is a number.
"+5 weeks", "12 day", "-7 weekdays"
'ago'
Negates all the values of previously found relative time items.
"2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months
ago 5 days", "2 days ago"
这是示例输出:
1554384488 <-- 2019-04-04 09:28:08
1554380888 <-- 2019-04-04 08:28:08
1554377288 <-- 2019-04-04 07:28:08
1554373688 <-- 2019-04-04 06:28:08
1554370088 <-- 2019-04-04 05:28:08
1554366488 <-- 2019-04-04 04:28:08
1554362888 <-- 2019-04-04 03:28:08
1554359288 <-- 2019-04-04 02:28:08
1554355688 <-- 2019-04-04 01:28:08
1554352088 <-- 2019-04-04 00:28:08
1554348488 <-- 2019-04-03 23:28:08
1554344888 <-- 2019-04-03 22:28:08
1554341288 <-- 2019-04-03 21:28:08
1554337688 <-- 2019-04-03 20:28:08
1554334088 <-- 2019-04-03 19:28:08
1554330488 <-- 2019-04-03 18:28:08
1554326888 <-- 2019-04-03 17:28:08
1554323288 <-- 2019-04-03 16:28:08
1554319688 <-- 2019-04-03 15:28:08
1554316088 <-- 2019-04-03 14:28:08
1554312488 <-- 2019-04-03 13:28:08
1554308888 <-- 2019-04-03 12:28:08
1554305288 <-- 2019-04-03 11:28:08
1554301688 <-- 2019-04-03 10:28:08
我从 now()
开始到 last 24 Hours
结束。我如何遍历 PHP 中的所有这些时间?
一次same time
一次和第二次loop
开始...
以下是您可能需要的此项目的 php 文档列表:
这里是 示例 代码,它将在一小时内给出最后 24 小时:
$timenow = time();
for ($i = 0; $i < 24; $i ++) {
$ago = strtotime("$i hours ago",$timenow);
echo $ago ," <-- ",strftime('%Y-%m-%d %H:%M:%S',$ago),"\n";
它使用相关格式中的这些格式:
number space? (unit | 'week')
Handles relative time items where the value is a number.
"+5 weeks", "12 day", "-7 weekdays"'ago'
Negates all the values of previously found relative time items.
"2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months ago 5 days", "2 days ago"
这是示例输出:
1554384488 <-- 2019-04-04 09:28:08
1554380888 <-- 2019-04-04 08:28:08
1554377288 <-- 2019-04-04 07:28:08
1554373688 <-- 2019-04-04 06:28:08
1554370088 <-- 2019-04-04 05:28:08
1554366488 <-- 2019-04-04 04:28:08
1554362888 <-- 2019-04-04 03:28:08
1554359288 <-- 2019-04-04 02:28:08
1554355688 <-- 2019-04-04 01:28:08
1554352088 <-- 2019-04-04 00:28:08
1554348488 <-- 2019-04-03 23:28:08
1554344888 <-- 2019-04-03 22:28:08
1554341288 <-- 2019-04-03 21:28:08
1554337688 <-- 2019-04-03 20:28:08
1554334088 <-- 2019-04-03 19:28:08
1554330488 <-- 2019-04-03 18:28:08
1554326888 <-- 2019-04-03 17:28:08
1554323288 <-- 2019-04-03 16:28:08
1554319688 <-- 2019-04-03 15:28:08
1554316088 <-- 2019-04-03 14:28:08
1554312488 <-- 2019-04-03 13:28:08
1554308888 <-- 2019-04-03 12:28:08
1554305288 <-- 2019-04-03 11:28:08
1554301688 <-- 2019-04-03 10:28:08