且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php日期小于另一个日期

更新时间:2023-01-29 09:31:41

p>比较时间戳:

  if(strtotime($ numeric。。 F))< time()){
//旧的
} else {
//新的
}
pre>

这是可能的 strtotime()返回从1.1.1970和 time()。在PHP中,你可以轻松地比较整数...


given this kind of date object date("m/d/Y", strtotime($numerical." ".$day." of ".date("F")))

where it may give a mm/dd/yyyy day that is the "first Monday of August", for instance

how can I decide if this date is greater than, less than, or equal to today's date?

I need a now() method that works in this format and can be compared between date objects

I haven't tried date() < date() , yet. But I don't think that will work

any insight appreciated

Compare the timestamps:

if (strtotime($numerical." ".$day." of ".date("F")) < time()) {
    // older
} else {
    // newer
}

This is possible as strtotime() returns the seconds since 1.1.1970 and time() too. And in PHP you can easily compare integers...