Re: Date +30 comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Stoltz wrote:
> I'm really struggling with dates in PHP. (Yes, I tried reading the
> manual)...
> 
> Can someone provide code that does this:
> 
> Takes current date, assigns it to a variable (let's say $today)
> Then adds 30 days to $today variable
> Takes a string ($nexteval) like '8/26/2009' and compare it to $today.
> 
> The variable $nexteval must be greater than $today (which is today + 30
> days) or a message is echoed.
> 
> I'm finding this difficult to do, but I'm coming from an ASP background.
> 
> Any help appreciated.

Look at the date/time functions, they are very feature rich:

$today = time();
$nexteval = strtotime('+30 days', $today);

if ($today > $nexteval) {
	echo 'Message';
}

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux