开发者

How to Compare Dates in php? [duplicate]

This question already has answers here: 开发者_JAVA百科 How can I compare two dates in PHP? (13 answers) Closed last year.

i need code to compare date in php

  1. Input date should be a valid date
  2. input date should not be less than the current date.
  3. i need to give time zones EST,PST,etc..
  4. We need to make the time to GMT and compare with Current Time.

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 converts the string in to the unix timestamp integer.


Take a look at the maketime() function. Then compare the resulting UNIX timestamps.


Check out Zend Framework's Date: http://framework.zend.com/manual/en/zend.date.overview.html You just need the Date.php file and the Date/Locale folders from the framework to use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜