duanrang2627 2011-06-21 15:14
浏览 59
已采纳

如何在两个时期内检索每个日期的数组

I have two epochs. I want to figure out all the dates that are valid within the two epochs.

For example, if I have the epochs 946684800 (Sat, 01 Jan 2000 00:00:00 GMT) and 947203200 (Fri, 07 Jan 2000 00:00:00 GMT), I want to be able to get: 01/01/2000, 02/01/2000, 03/01/2000, 04/01/2000, etc.

  • 写回答

6条回答 默认 最新

  • duanhan9479 2011-06-21 15:19
    关注

    PHP time values are just Unix timestamps - seconds since Jan 1/1970. Going off PHP 5's datetime object:

    $start = strtotime('01 Jan 2000');
    $end = strtotime('07 Jan 2000');
    
    for ($d = $start; $d <= $end; $d += 86400) { // increment by 86,400 seconds, aka 1 day
        echo date('d/m/Y', $d);
    }
    

    There's better ways of going about it, using the DateTime / DateInterval objects, but this is just to show the basics.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services