Angular Component to Convert Date into pretty facebook like time stamps

Looking for human readable user friendly data to time stamps using angularjs If then in this post I am going to share Angular Component to Convert Date into pretty Facebook, twitter like date conversion in Angular using angular pipes which support angular8.


Input Output
Date object just now
Date object minus one minute 1 minute ago
Date object minus 5 minute 5 minutes ago
Date object minus 1 hour 1 hour ago
Date object minus 5 hours 5 hours ago
Date object minus 1 day Yesterday
Date object minus 4 days 4 days ago
Date object minus 17 days 3 weeks ago
Date object minus 45 days 2 months ago
Date object minus 366 days more than a year ago
2019-12-24T06:18:44 2 months ago
Text String Invalid Date

Getting Started

Install via npm

npm install –save ngx-pretty-date

Import the module

import { NgxPrettyDateModule } from 'ngx-pretty-date';

  declarations: [
  imports: [
  bootstrap: [...]
export class AppModule { }

Use in components

<span> {{dateObj | prettyDate}} </span>

You can pass javascript date object or string like this ‘2019-12-24T06:18:44’

See live demo and download source code.


This awesome script developed by keshavkhatri. Visit their official repository for more information and follow for future updates.

Don’t forget to Subscribe My Public Notebook for more useful free scripts, tutorials and articles.