How to calculate “time ago” in Java?

Take a look at the PrettyTime library. It’s quite simple to use: import org.ocpsoft.prettytime.PrettyTime; PrettyTime p = new PrettyTime(); System.out.println(p.format(new Date())); // prints “moments ago” You can also pass in a locale for internationalized messages: PrettyTime p = new PrettyTime(new Locale(“fr”)); System.out.println(p.format(new Date())); // prints “à l’instant” As noted in the comments, Android has this … Read more

How to calculate the difference between two dates using PHP?

I suggest to use DateTime and DateInterval objects. $date1 = new DateTime(“2007-03-24”); $date2 = new DateTime(“2009-06-26”); $interval = $date1->diff($date2); echo “difference ” . $interval->y . ” years, ” . $interval->m.” months, “.$interval->d.” days “; // shows the total amount of days (not divided into years, months and days like above) echo “difference ” . $interval->days … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)