php日期小于另一个日期

编程入门 行业动态 更新时间:2024-10-27 08:35:32
本文介绍了php日期小于另一个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

给定这种日期对象 日期(m / d / Y,strtotime($ numeric。$ day。of.date(F) ))

其中它可以给出八月的第一个星期一的mm / dd / yyyy日期,例如

如何判断此日期是否大于,小于或等于今天的日期?

我需要 now()方法,工作在此格式,可以在日期对象之间进行比较

() date()。

解决方案

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...

更多推荐

php日期小于另一个日期

本文发布于:2023-05-26 10:05:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/353345.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!