X-Y-Z日期之前有多少天? [英] How many days until X-Y-Z date?

查看:98
本文介绍了X-Y-Z日期之前有多少天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个特定的日期,最简单的方法是确定直到那个日期的几天(PHP)?我正在尝试构建一个倒计时的小部件,谢谢!

解决方案

  php 
$ cdate = mktime(0,0,0,12,31,2009,0);
$ today = time();
$ difference = $ cdate - $ today;
if($ difference< 0){$ difference = 0; }
echo有。 ($差异/ 60/60/24)。
?>


Given a certain date, whats the easiest way to determine how many days until that date (in PHP)? I am trying to build a count-down widget, Thanks!

解决方案

<?php 
$cdate = mktime(0, 0, 0, 12, 31, 2009, 0);
$today = time();
$difference = $cdate - $today;
if ($difference < 0) { $difference = 0; }
echo "There are ". floor($difference/60/60/24)." days remaining";
?>

这篇关于X-Y-Z日期之前有多少天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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