Jump to content

plz help if u can..:)


tauchai83

Recommended Posts

i hav date problems. I have create a date that receive input $day, $month, $year separately from the user. (through drop down box).

Now i trying to get the expired date (appointment date) show up an "done" IMAGE. automatically by comparing with today's date. How should I do that? so far what i have coded work in reverse.

Here is my coding: what's wrong with it?

[color=blue]$bkdate = $Day."-".$Month."-".$Year;  (user input variable)
$today = date("d-m-Y"); (today date in format of 19-01-2007)

if($bkdate<$today )
{
echo "<td><img src=\"images/bullet.gif\" width=\"24\" height=\"24\" border=\"0\"></a></td>";
}[/color]

i try to use string compare function but it did not work as i want. who can help me? Thanks!! :)
Link to comment
https://forums.phpfreaks.com/topic/34860-plz-help-if-u-can/
Share on other sites

I find that comparing dates in this way do now work correctly because it's verifying strings, not dates

this will work:

[code]
<?php

$bkdate = "{$Year}-{$Month}-{$Day}";
$today = date("Y-m-d");

if(strtotime($bkdate)<strtotime($today) )
{
  // echo here
}
?>
[/code]

Dates are represented like string but to make calculations and comparings you should convert them in numbers.

php do not parse any string to find if it´s numeric or date or a boolean or anything else before comparing... you must parse (or convert) before making your test...
Link to comment
https://forums.phpfreaks.com/topic/34860-plz-help-if-u-can/#findComment-164511
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.