如何在php中比较日期? [英] How to Compare Dates in php?

查看:131
本文介绍了如何在php中比较日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要代码来比较php中的日期

i need code to compare date in php

  1. 输入日期应为有效日期
  2. 输入日期不能小于当前日期.
  3. 我需要指定时区EST,PST等.
  4. 我们需要花时间到格林尼治标准时间,并与当前时间"进行比较.

任何人都可以帮忙. 谢谢 Ramakrishnan.p

can anyone help on this. Thanks Ramakrishnan.p

推荐答案

这是一个较晚的答案.由于此处没有确切的问题答案,因此我在此处提供此解决方案.

This is a late answer. since there is no exact answer to the question here, I'm providing this solution here.

您可以通过这种方式完成

You can do it in this way

$date1 = strtotime("2007-02-20"); // your input
$date2 = strtotime("today"); //today
if($date1 < $date2) {
    echo " input date is in the past";
}

strtotime将字符串转换为unix时间戳整数.

strtotime converts the string in to the unix timestamp integer.

这篇关于如何在php中比较日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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