<tfoot id='oQGfK'></tfoot>
  1. <i id='oQGfK'><tr id='oQGfK'><dt id='oQGfK'><q id='oQGfK'><span id='oQGfK'><b id='oQGfK'><form id='oQGfK'><ins id='oQGfK'></ins><ul id='oQGfK'></ul><sub id='oQGfK'></sub></form><legend id='oQGfK'></legend><bdo id='oQGfK'><pre id='oQGfK'><center id='oQGfK'></center></pre></bdo></b><th id='oQGfK'></th></span></q></dt></tr></i><div id='oQGfK'><tfoot id='oQGfK'></tfoot><dl id='oQGfK'><fieldset id='oQGfK'></fieldset></dl></div>

        <bdo id='oQGfK'></bdo><ul id='oQGfK'></ul>
    1. <legend id='oQGfK'><style id='oQGfK'><dir id='oQGfK'><q id='oQGfK'></q></dir></style></legend>
    2. <small id='oQGfK'></small><noframes id='oQGfK'>

      在php中查找2个unix时间戳之间的天数

      Finding days between 2 unix timestamps in php(在php中查找2个unix时间戳之间的天数)
          <tbody id='eDJRN'></tbody>

        1. <i id='eDJRN'><tr id='eDJRN'><dt id='eDJRN'><q id='eDJRN'><span id='eDJRN'><b id='eDJRN'><form id='eDJRN'><ins id='eDJRN'></ins><ul id='eDJRN'></ul><sub id='eDJRN'></sub></form><legend id='eDJRN'></legend><bdo id='eDJRN'><pre id='eDJRN'><center id='eDJRN'></center></pre></bdo></b><th id='eDJRN'></th></span></q></dt></tr></i><div id='eDJRN'><tfoot id='eDJRN'></tfoot><dl id='eDJRN'><fieldset id='eDJRN'></fieldset></dl></div>

              <tfoot id='eDJRN'></tfoot>
            • <legend id='eDJRN'><style id='eDJRN'><dir id='eDJRN'><q id='eDJRN'></q></dir></style></legend>

              <small id='eDJRN'></small><noframes id='eDJRN'>

                <bdo id='eDJRN'></bdo><ul id='eDJRN'></ul>

              • 本文介绍了在php中查找2个unix时间戳之间的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                嘿,我有一个保存事件的数据库.有 2 个字段开始"和结束",它们包含时间戳.当管理员输入这些日期时,他们只能设置日、月、年.所以我们只处理包含天、月、年的戳记,而不是小时、分钟、秒(小时、分钟和秒设置为 0,0,0).

                Hay, i have a database holding events. There are 2 fields 'start' and 'end', these contain timestamps. When an admin enters these dates, they only have the ability to set the day,month,year. So we are only dealing with stamps containing days,months,years, not hours,minutes,seconds (hours,minutes and seconds are set to 0,0,0).

                我有一个事件,开始时间为 1262304000,结束时间为 1262908800.这些转换为 2010 年 1 月 1 日和 2010 年 1 月 8 日.我如何获得这些时间戳之间的所有天数?我希望能够返回 2010 年 1 月 2 日 (1262390400)、2010 年 1 月 3 日 (1262476800) .. 一直到最后的邮票.这些事件可能会跨越不同的月份,比如 5 月 28 日到 6 月 14 日.

                I have an event with the start time as 1262304000 and the end time as 1262908800. These convert to Jan 1 2010 and Jan 8 2010. How would i get all the days between these timestamps? I want to be able to return Jan 2 2010 (1262390400), Jan 3 2010 (1262476800) .. all the way to the end stamp. These events could cross over into different months, say May 28 to June 14.

                任何想法如何做到这一点?

                Any ideas how to do this?

                推荐答案

                你只需要计算两个日期之间的秒数,然后除以得到天数:

                You just have to calculate the number of seconds between the two dates, then divide to get days :

                $numDays = abs($smallestTimestamp - $biggestTimestamp)/60/60/24;
                

                然后,您可以使用 for 循环来检索日期:

                Then, you can use a for loop to retrieve the dates :

                $numDays = abs($smallestTimestamp - $biggestTimestamp)/60/60/24;
                
                for ($i = 1; $i < $numDays; $i++) {
                    echo date('Y m d', strtotime("+{$i} day", $smallestTimestamp)) . '<br />';
                }
                

                同样,如果您不知道哪个时间戳最小,您可以使用 min() 函数(strtotime 中的第二个参数).

                Again, if you don't know which timestamp is the smallest, you can use the min() function (second argument in strtotime).

                这篇关于在php中查找2个unix时间戳之间的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Converting string to MySQL timestamp format in php(在php中将字符串转换为MySQL时间戳格式)
                datetime to timestamp(日期时间到时间戳)
                PHP timestamp date to user timezone(PHP时间戳日期到用户时区)
                Converting TIMESTAMP to unix time in PHP?(在 PHP 中将 TIMESTAMP 转换为 unix 时间?)
                Convert ISO 8601 to unixtimestamp(将 ISO 8601 转换为 unixtimestamp)
                Difference between 2 time() values(2 time() 值之间的差异)
                  <bdo id='xfcld'></bdo><ul id='xfcld'></ul>
                  <legend id='xfcld'><style id='xfcld'><dir id='xfcld'><q id='xfcld'></q></dir></style></legend>

                      <tbody id='xfcld'></tbody>
                  • <tfoot id='xfcld'></tfoot>
                  • <i id='xfcld'><tr id='xfcld'><dt id='xfcld'><q id='xfcld'><span id='xfcld'><b id='xfcld'><form id='xfcld'><ins id='xfcld'></ins><ul id='xfcld'></ul><sub id='xfcld'></sub></form><legend id='xfcld'></legend><bdo id='xfcld'><pre id='xfcld'><center id='xfcld'></center></pre></bdo></b><th id='xfcld'></th></span></q></dt></tr></i><div id='xfcld'><tfoot id='xfcld'></tfoot><dl id='xfcld'><fieldset id='xfcld'></fieldset></dl></div>

                      <small id='xfcld'></small><noframes id='xfcld'>