[英]Compare HTML5 date input with Angular2 date
I wanted compare the date (input type="date" in HTML5) with the date Objekt in Angular2 but there is no way to compare them. 我想比较日期(输入类型= HTML5中的“日期”)和Angular2中的日期Objekt,但无法比较它们。 I there a easy way to do it ? 我有一个简单的方法吗?
<label> Create Date: </label>
<input class="form-control" [ngModel]="chart.createDate"
(ngModelChange)="chart.createDate = $event"
type="date"
data-date="" data-date-format="DD MMMM YYYY"
required #createDate="ngModel" name="createDate"/>
<div *ngIf="Date.parse(chart.createDate).getTime() < dateControll.getTime()">
- date is older than today
</div>
I did it like this: 我是这样做的:
if (varDate1.valueOf() > varDate2.valueOf()) {
// do this and that...
}
but both needs to be defined as Date in Angular... 但两者都需要定义为Angular中的Date ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.