简体   繁体   中英

PHP is date past due?

Ok, I have a "due date" formatted like this: 08/31/2012 (M/D/Y). What I would like to do using PHP compare the returned string as shown against the current date. If the string above is older than the current date...execute some code.

I know this seems simple but it is throwing me for a loop.

thanks for any help!

Do you mean that if the string-date is older do this and if not do that?

<?php

$string = '08/31/2012';
if(strtotime($string) < time()){
    echo 'Old';
}else{
    echo 'Not happened yet';
}

更改为格式YYYY-MM-DD并简单地比较为字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM