Angular6 如何在Ionic 4中获取日期对象
我想在Ionic 4中获得Date对象,但是我没有找到Date,我无法编译代码Angular6 如何在Ionic 4中获取日期对象,angular6,ionic4,Angular6,Ionic4,我想在Ionic 4中获得Date对象,但是我没有找到Date,我无法编译代码 import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-bookingdetail', templateUrl: './bookingdetail.page.html', styleUrls: ['./bookingdetail.page.scss'], }) export class Booking
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-bookingdetail',
templateUrl: './bookingdetail.page.html',
styleUrls: ['./bookingdetail.page.scss'],
})
export class BookingdetailPage implements OnInit {
d = new Date();
}
将变量指定给日期类型。 然后,为了便于使用,您可以在加载页面时通过控制台记录结果
export class BookingdetailPage implements OnInit {
d: Date = new Date();
}
ngOnInit() {
console.log(this.d);
}
输出(在控制台中)
2019年1月21日(星期一)08:35:52 GMT+0100(欧洲中部标准)
要在IONIC 4中设置组件,请使用toISOString函数:
<ion-datetime [value]="today"></ion-datetime>
ngOnInit() {
const now = new Date();
this.today = now.toISOString();
}
恩戈尼尼特(){
const now=新日期();
this.today=now.toISOString();
}
我尝试了这个,但同样的结果我无法编译它。我用的是离子4和角离子6@Kuldeep奇怪!你能用准确的错误信息更新你的问题吗?