diff --git a/src/ng2-datetime/ng2-datetime.ts b/src/ng2-datetime/ng2-datetime.ts index 2769dd9e..817b37db 100644 --- a/src/ng2-datetime/ng2-datetime.ts +++ b/src/ng2-datetime/ng2-datetime.ts @@ -123,7 +123,7 @@ export class NKDatetime implements ControlValueAccessor, AfterViewInit, OnDestro } writeValue(value: any) { - this.date = value; + this.date = new Date(value); if (isDate(this.date)) { setTimeout(() => { this.updateModel(this.date); @@ -266,5 +266,5 @@ function uniqueId(prefix: string): string { } function isDate(obj: any) { - return Object.prototype.toString.call(obj) === '[object Date]'; + return obj && obj.toString() !== 'Invalid Date'; }