Ok i have this long bit of code that determines how long ago someone input a post or comment. The only bit of the code that is giving me problems is at the very beginning. When i place a fresh topic or comment it doesn't go into the " just a moment ago ". I dont know why it just doesn't seem to go into that piece of code. HELP PLEASE. Heres the code. safetimestamp is the time stamp that was placed into the database.
$diff = time() - $safetimestamp;
$second="1";
$minute="60";
$hour="3600";
$day="86400";
$week="604800";
$month="2592000";
$year="31536000";
if($diff> $year){
if($diff > ($year * 3)){
$time = "over 3 years old";
}else{
if($diff > $year * 2){
$time ="over 2 years old";
}else{
$time ="over 1 year old";
}
}
}else{
if($diff > $month){
if($diff > ($month * 6)){
$time = "over 6 months old";
}else{
if($diff > ($month * 3)){
$time = "over 3 months old";
}else{
$time = "over 1 month old";
}
}
}else{
if($diff > $week){
if($diff > ($week * 3)){
$time = "over 3 weeks old";
}else{
if($diff > ($week * 2)){
$time = "over 2 weeks old";
}else{
$time = "over 1 week old";
}
}
}else{
if($diff > $day){
if($diff > ($day * 6)){
$time = " 6 days old";
}else{
if($diff > ($day * 5)){
$time = " 5 days old";
}else{
if($diff > ($day * 4)){
$time = " 4 days old";
}else{
if($diff > ($day * 3)){
$time = " 3 days old";
}else{
if($diff > ($day * 2)){
$time = " 2 days old";
}else{
if($diff > $day){
$time = "1 day old";
}else{
}
}
}
}
}
}
}else{
if($diff > $hour){
if($diff > ($hour * 23)){
$time = " 23 hours ago ";
}else{
if($diff > ($hour * 22)){
$time = " 22 hours ago ";
}else{
if($diff > ($hour * 21)){
$time = " 21 hours ago ";
}else{
if($diff > ($hour * 20)){
$time = " 20 hours ago ";
}else{
if($diff > ($hour * 19)){
$time = " 19 hours ago ";
}else{
if($diff > ($hour * 18)){
$time = " 18 hours ago ";
}else{
if($diff > ($hour * 17)){
$time = " 17 hours ago ";
}else{
if($diff > ($hour * 16)){
$time = " 16 hours ago ";
}else{
if($diff > ($hour * 15)){
$time = " 15 hours ago ";
}else{
if($diff > ($hour * 14)){
$time = " 14 hours ago ";
}else{
if($diff > ($hour * 13)){
$time = " 13 hours ago ";
}else{
if($diff > ($hour * 12)){
$time = " 12 hours ago ";
}else{
if($diff > ($hour * 11)){
$time = " 11 hours ago ";
}else{
if($diff > ($hour * 10)){
$time = " 10 hours ago ";
}else{
if($diff > ($hour * 9)){
$time = " 9 hours ago ";
}else{
if($diff > ($hour * 8)){
$time = " 8 hours ago ";
}else{
if($diff > ($hour * 7)){
$time = " 7 hours ago ";
}else{
if($diff > ($hour * 6)){
$time = " 6 hours ago ";
}else{
if($diff > ($hour * 5)){
$time = " 5 hours ago ";
}else{
if($diff > ($hour * 4)){
$time = " 4 hours ago ";
}else{
if($diff > ($hour * 3)){
$time = " 3 hours ago ";
}else{
if($diff > ($hour * 2)){
$time = " 2 hours ago ";
}else{
if($diff > ($hour)){
$time = " 1 hour ago ";
}else{
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}else{
if($diff > $minute){
if($diff > ($minute * 60)){
$time = " 60 minutes ago ";
}else{
if($diff > ($minute * 59)){
$time = " 59 minutes ago ";
}else{
if($diff > ($minute * 58)){
$time = " 58 minutes ago ";
}else{
if($diff > ($minute * 57)){
$time = " 57 minutes ago ";
}else{
if($diff > ($minute * 56)){
$time = " 56 minutes ago ";
}else{
if($diff > ($minute * 55)){
$time = " 55 minutes ago ";
}else{
if($diff > ($minute * 54)){
$time = " 54 minutes ago ";
}else{
if($diff > ($minute * 53)){
$time = " 53 minutes ago ";
}else{
if($diff > ($minute * 52)){
$time = " 52 minutes ago ";
}else{
if($diff > ($minute * 51)){
$time = " 51 minutes ago ";
}else{
if($diff > ($minute * 50)){
$time = " 50 minutes ago ";
}else{
if($diff > ($minute * 49)){
$time = " 49 minutes ago ";
}else{
if($diff > ($minute * 48)){
$time = " 48 minutes ago ";
}else{
if($diff > ($minute * 47)){
$time = " 47 minutes ago ";
}else{
if($diff > ($minute * 46)){
$time = " 46 minutes ago ";
}else{
if($diff > ($minute * 45)){
$time = " 45 minutes ago ";
}else{
if($diff > ($minute * 44)){
$time = " 44 minutes ago ";
}else{
if($diff > ($minute * 43)){
$time = " 43 minutes ago ";
}else{
if($diff > ($minute * 42)){
$time = " 42 minutes ago ";
}else{
if($diff > ($minute * 41)){
$time = " 41 minutes ago ";
}else{
if($diff > ($minute * 40)){
$time = " 40 minutes ago ";
}else{
if($diff > ($minute * 39)){
$time = " 39 minutes ago ";
}else{
if($diff > ($minute * 38)){
$time = " 38 minutes ago ";
}else{
if($diff > ($minute * 37)){
$time = " 37 minutes ago ";
}else{
if($diff > ($minute * 36)){
$time = " 36 minutes ago ";
}else{
if($diff > ($minute * 35)){
$time = " 35 minutes ago ";
}else{
if($diff > ($minute * 34)){
$time = " 34 minutes ago ";
}else{
if($diff > ($minute * 33)){
$time = " 33 minutes ago ";
}else{
if($diff > ($minute * 32)){
$time = " 32 minutes ago ";
}else{
if($diff > ($minute * 31)){
$time = " 31 minutes ago ";
}else{
if($diff > ($minute * 30)){
$time = " 30 minutes ago ";
}else{
if($diff > ($minute * 29)){
$time = " 29 minutes ago ";
}else{
if($diff > ($minute * 28)){
$time = " 28 minutes ago ";
}else{
if($diff > ($minute * 27)){
$time = " 27 minutes ago ";
}else{
if($diff > ($minute * 26)){
$time = " 26 minutes ago ";
}else{
if($diff > ($minute * 25)){
$time = " 25 minutes ago ";
}else{
if($diff > ($minute * 24)){
$time = " 24 minutes ago ";
}else{
if($diff > ($minute * 23)){
$time = " 23 minutes ago ";
}else{
if($diff > ($minute * 22)){
$time = " 22 minutes ago ";
}else{
if($diff > ($minute * 21)){
$time = " 21 minutes ago ";
}else{
if($diff > ($minute * 20)){
$time = " 20 minutes ago ";
}else{
if($diff > ($minute * 19)){
$time = " 19 minutes ago ";
}else{
if($diff > ($minute * 18)){
$time = " 18 minutes ago ";
}else{
if($diff > ($minute * 17)){
$time = " 17 minutes ago ";
}else{
if($diff > ($minute * 16)){
$time = " 16 minutes ago ";
}else{
if($diff > ($minute * 15)){
$time = " 15 minutes ago ";
}else
if($diff > ($minute * 14)){
$time = " 14 minutes ago ";
}else{
if($diff > ($minute * 13)){
$time = " 13 minutes ago ";
}else{
if($diff > ($minute * 12)){
$time = " 12 minutes ago ";
}else{
if($diff > ($minute * 11)){
$time = " 11 minutes ago ";
}else{
if($diff > ($minute * 10)){
$time = " 10 minutes ago ";
}else{
if($diff > ($minute * 9)){
$time = " 9 minutes ago ";
}else{
if($diff > ($minute * 8)){
$time = " 8 minutes ago ";
}else{
if($diff > ($minute * 7)){
$time = " 7 minutes ago ";
}else{
if($diff > ($minute * 6)){
$time = " 6 minutes ago ";
}else{
if($diff > ($minute * 5)){
$time = " 5 minutes ago ";
}else{
if($diff > ($minute * 4)){
$time = " 4 minutes ago ";
}else{
if($diff > ($minute * 3)){
$time = " 3 minutes ago ";
}else{
if($diff > ($minute * 2)){
$time = " 2 minutes ago ";
}else{
if($diff > $minute){
$time = " 1 minute ago ";
}else{
$time = " just a moment ago ";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}