RE: [PHP] Messing with Dates
| From: | Joao Prado Maia | Date: | Tue, 29 Aug 2000 18:14:37 +0000 |
| Subject: | RE: [PHP] Messing with Dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14199@lists.php.net to get a copy of this message | ||
On Tue, 29 Aug 2000, Craig Vincent wrote:
> > I'm assuming that your last_updated field has the DATETIME datatype. You
> > have first of all to convert that to a UNIX timestamp, and then compare to
> > the substraction of the timestamp of "right now" and a month ago. I'm also
> > assuming that "a month ago" means 30 days. You might want to check for 31
> > day months if you are really paranoid.
>
> Why not let mktime do the check...then it will handle 30/31 (and 28) day
> months properly :)
>
> <?
> $last = mysql_query(...);
> list($hour, $min, $sec, $day, $mon, $yr) = explode(" ",date("H i s d m
> y"));
> if (date('Y-m-d H:i:s',mktime($hour, $min, $sec, $mon-1, $day, $yr) > $last)
> {
> echo 'More than a month has passed';
> }
> else {
> echo 'Less than a month has passed';
> }
> ?>
Well, I told you guys that there was probably a better way to do
it. That's going to go into my "Tips" folder heh.
Joao
--
Joao Prado Maia
Web Developer
Kefta.com, Inc