Skip to content

Instantly share code, notes, and snippets.

@Qarun-Qadir-Bissoondial
Created April 3, 2020 12:44
Show Gist options
  • Save Qarun-Qadir-Bissoondial/96313b62cad03e541b615f0329e515de to your computer and use it in GitHub Desktop.
Save Qarun-Qadir-Bissoondial/96313b62cad03e541b615f0329e515de to your computer and use it in GitHub Desktop.
Pipes Demo - Date Pipe
import { Component } from '@angular/core';
@Component({
selector: 'app-date-pipe',
template: `
<p>Date without Pipe: {{date}}</p>
<p>Date with Pipe: {{date | date}} </p>
<h3>Showing Dates</h3>
<p>Short Date: {{date | date:'shortDate'}}</p>
<p>Medium Date: {{date | date:'mediumDate'}}</p>
<p>Long Date: {{date | date:'longDate'}}</p>
<h3>Dates with Parameters</h3>
<p>dd/mm/yyyy: {{date | date:'d MMM y'}}</p>
<p>yyyy/mm/dd: {{date | date:'y MMM d'}}</p>
<h3>Formatting Times</h3>
<p>Short time: {{date | date:'shortTime'}}</p>
<p>Medium time: {{date | date:'mediumTime'}}</p>
<p>Long time: {{date | date:'longTime'}}</p>
`,
styleUrls: []
})
export class DatePipeComponent {
date: Date = new Date();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment