Angular Date pipe in component ts file

This article will show you how to use Angular Date pipe in component ts file.

To achieve the same we need to import `DatePipe` exported function from angular core modules.

import { DatePipe } from '@angular/common';

  transform() {
    return new DatePipe("en-US").transform(new Date(), 'EEEE, MMMM d, y');
  }

The above function return formatted date as per the custom format passed. The given date is `new Date()` which is current date generated from Date funciton.

Leave a Reply

Your email address will not be published. Required fields are marked *