Calculate time like in messenger app

Hi ionites,

I am just curious if I can achieve the time like in messenger app. When it is not past 24/present date it will display the time and when it does past 24 hrs but not less than a week it will display Mon - Sun and so on for the logic.. I use time-ago but I think it doesn't suits my taste for calculating time.. Thanks..