I need to know how you can subtract two dates.
I have a MySQL Database full of profile information. I need the table to display an image that depends on how long the person has been a member.
The problem i am having is that it is not having the result i thought it would have and it is because my date math is not working correctly.
Can you look at the following code and tell me-
How to do the correct date math?
What type of an expression do I use so that the correct award is shown (i.e. members that have been inservice BETWEEN 1 month and 2 months)?
#######################
Get the time info
#######################
$format = getdate(time());
$year = $format['year'];
$month = $format['mon'];
$day = $format['mday'];
$checkdate = "$year-$month-$day";
######################################
Get ready for the Display Loop!!
######################################
while ($row1 = mysql_fetch_array($Result1)){
IF ($row1[datejoin]-$checkdate >= 0000-01-00) {
$award = "<img src='http://www.mysite.com/images/Awards/medal2.gif'>";
}
IF ($row1[datejoin]-$checkdate >= 0000-02-00) {
$award = "<img src='http://www.mysite.com/images/Awards/medal0.gif'>";
}
print("<TR VALIGN=LEFT>");
print("<TD VALIGN=LEFT>$award</TD>");
print("<TD VALIGN=LEFT>$row1[user]</TD>");
print("<TD VALIGN=LEFT>$row1[position]</TD>");
print("<TD VALIGN=LEFT>$row1[datejoin]</TD>");
print("</TR>");
}