如何在PHP中从一个日期到另一个日期获取整数 [英] How to get integer number from one date to another in PHP

查看:71
本文介绍了如何在PHP中从一个日期到另一个日期获取整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想说的是Y-MM-DD的日期,比如说上周到现在.

Hey guys so I am trying to get the date lets say Y-MM-DD from, lets say last week to now.

所以:

2013-4-8至2013-4-15<-所以我想将两者之间的距离变成一个整数,因此应该为7.

2013-4-8 through 2013-4-15 <-- so I want to turn the distance between these two into an integer so it should be 7.

我的问题是我怎么得到那个号码?

My question is how do I get that number?

大卫

推荐答案

以一种时尚的方式:

$start = '2013-4-8';
$end = '2013-4-15';
$diff = count(range(strtotime($start), strtotime($end),86400))-1;
echo $diff;

在线演示

这篇关于如何在PHP中从一个日期到另一个日期获取整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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