创建最近30天使用PHP数组 [英] Create an Array of the Last 30 Days Using PHP

查看:417
本文介绍了创建最近30天使用PHP数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个数组开始,今天回去最近30天的PHP和我有麻烦。我可以估算,但我不知道这样做,并考虑到天数在previous月等有没有人有一个很好的解决方案的好方法?我无法靠近,但我需要确保它是100%准确。

I am trying to create an array starting with today and going back the last 30 days with PHP and I am having trouble. I can estimate but I don’t know a good way of doing it and taking into account the number of days in the previous month etc. Does anyone have a good solution? I can’t get close but I need to make sure it is 100% accurate.

推荐答案

试试这个:

<?php    
$d = array();
for($i = 0; $i < 30; $i++) 
    $d[] = date("d", strtotime('-'. $i .' days'));
?>

这篇关于创建最近30天使用PHP数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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