Last active
June 12, 2017 07:43
-
-
Save JonathanDn/d1b14269e91dcb90fed648202de7ed55 to your computer and use it in GitHub Desktop.
Angular 2 - Javascript Vanilla - getDateNow() --> 'dd/mm/yyy hh:mm'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, OnInit} from '@angular/core'; | |
@Component({ | |
selector: 'app', | |
templateUrl: 'app.html', | |
styleUrls: ['app.scss'] | |
}) | |
export class AppComponent implements OnInit { | |
private d; | |
private dateFormat; | |
constructor() {} | |
ngOnInit() { | |
this.setDateNow(); | |
} | |
setDateNow() { | |
this.d = new Date(); | |
this.dateFormat = [this.d.getMonth(), this.d.getDay(), this.d.getFullYear()].join('.') + ' ' + [ this.d.getHours(), this.d.getSeconds()].join(':'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment