adding date variable to an int variable....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

adding date variable to an int variable....

Post by DynamiteHost »

Any idea why this code doesnt work? $amount can be anything between 1 and 12. When I try to put it into a mysql db table, it simply leaves the field empty.

Code: Select all

$day = date("d");
if ($timescale == "monthly") {
$month = date("m");
$month+$amount;
}
else {
$year = date("y");
$year+$amount;
}

Thanks all :D
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

try something more like

Code: Select all

$day = date("d"); 
if ($timescale == "monthly") { 
$month = date("m"); 
$value = $month+$amount; 
} 
else { 
$year = date("y"); 
$value = $year+$amount; 
}
and the information will be stored in '$value', you were adding them, just not putting the returned value into anything.
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Post by DynamiteHost »

Thanks for the help, it worked 8)
Post Reply