angular current date time code example
Example 1: pipe of date angular
content_copy
{{ dateObj | date }}
{{ dateObj | date:'medium' }}
{{ dateObj | date:'shortTime' }}
{{ dateObj | date:'mm:ss' }}
Example 2: angular get current time
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `{{ now }}`
})
export class AppComponent {
public now: Date = new Date();
constructor() {
setInterval(() => {
this.now = new Date();
}, 1);
}
}
Example 3: angular date pipi locale
<p>French date time is {{todayDate | date:'full':'+0200':'fr'}}</p>
Result:
French date time is mercredi 19 juin 2019 à 13:25:15 GMT+02:00
Example 4: how to display current date and time in angular
setTimeout(
function(){
location.reload();
}, 60000);