Converting UNIX timestamp to seconds, minutes, hours, days, weeks, month, years, decades ago

Leave a comment  →

If you have UNIX time-stamps and you want convert it to show how may seconds, minutes, hours, weeks, months, years or decades ago it is from now you may use the following snippet of code. It accepts UNIX time-stamp in long format, In case you are getting UNIX time-stamps in String format you have to convert it to long. It will return a string with either seconds, minutes , hours , days, weeks, months, years , or decades ago. The code is written in java for an android app but can be ported to any language. Here is the code which is also available on github.


RECOMMENDED READ  isOnline() check if android device has internet connectivity


Leave a Reply