$date1 larger then current date?
am 24.04.2007 11:38:00 von Gustav Wiberg
Hi guys!
=20
I'm searching for what I thought would be an easy issue comparing dates. I =
just want to know if a date in variable
$date1 is larger then current date.=20
=20
I use the format YYYY-MM-DD in $date1
and I know how to retrieve the current date and set it in $dat2
=20
But how do I know if $date1> $date2 ?
=20
I have looked around, but I havent found any easy solution. It seems to be =
a big deal? Is that the case?
=20
Best regards
/Gustav Wiberg
=20
=20
=20
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: $date1 larger then current date?
am 24.04.2007 12:58:08 von php
Try:
if ($date1 > $date2) {
echo "First date is a later one than Second date";
} else {
echo "Second date is the latest.";
}
It's just as easy as you thought it'd be.
Mike
Gustav Wiberg skrev:
> Hi guys!
>
>
> I'm searching for what I thought would be an easy issue comparing dates. I just want to know if a date in variable
> $date1 is larger then current date.
>
> I use the format YYYY-MM-DD in $date1
> and I know how to retrieve the current date and set it in $dat2
>
> But how do I know if $date1> $date2 ?
>
> I have looked around, but I havent found any easy solution. It seems to be a big deal? Is that the case?
>
>
> Best regards
> /Gustav Wiberg
>
>
>
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: $date1 larger then current date?
am 24.04.2007 14:15:03 von Jarrett Meyer
--0-939777206-1177416903=:75910
Content-Type: text/plain; charset=ascii
if (mktime(0,0,0,substr($date1,5,2),substr($date1,8,2),substr($ date1,0,4)) > time() ) // if $date1 > server time
{
//do stuff
}
I have a few conversions that I use. Our server stores all dates in YYYYMMDD (as int) format, so I've got a few handy functions (OsDateToTimestamp(OsDate) and TimestampToOsDate(Timestamp)) that seem to get called a LOT.
Thank you,
Jarrett Meyer
http://jarrettmeyer.blogspot.com
No trees were harmed during this transmission; however, several electrons were terribly inconvenienced.
----- Original Message ----
From: Gustav Wiberg
To: "'php windows' (php-windows@lists.php.net)"
Sent: Tuesday, April 24, 2007 5:38:00 AM
Subject: [PHP-WIN] $date1 larger then current date?
Hi guys!
I'm searching for what I thought would be an easy issue comparing dates. I just want to know if a date in variable
$date1 is larger then current date.
I use the format YYYY-MM-DD in $date1
and I know how to retrieve the current date and set it in $dat2
But how do I know if $date1> $date2 ?
I have looked around, but I havent found any easy solution. It seems to be a big deal? Is that the case?
Best regards
/Gustav Wiberg
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--0-939777206-1177416903=:75910--