Skip to content

Instantly share code, notes, and snippets.

@JonathanDn
Last active June 12, 2017 07:43
Show Gist options
  • Save JonathanDn/d1b14269e91dcb90fed648202de7ed55 to your computer and use it in GitHub Desktop.
Save JonathanDn/d1b14269e91dcb90fed648202de7ed55 to your computer and use it in GitHub Desktop.
Angular 2 - Javascript Vanilla - getDateNow() --> 'dd/mm/yyy hh:mm'
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