Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angular2/4上的getDate()出错_Angular_Typescript_Timestamp_Getdate - Fatal编程技术网

angular2/4上的getDate()出错

angular2/4上的getDate()出错,angular,typescript,timestamp,getdate,Angular,Typescript,Timestamp,Getdate,我使用的是Angular 4,但我在从输入中获取日期时遇到问题 我正在使用“angular2 datetimepicker”(查看这里-->),这样我也可以设置时间 这是我的html: <angular2-date-picker [(ngModel)]="fromDate" [settings]="settings"></angular2-date-picker> 然后,我想将变量fromDate转换为时间戳格式;我试过使用这个,但不起作用: Math.floor(th

我使用的是Angular 4,但我在从输入中获取日期时遇到问题

我正在使用“angular2 datetimepicker”(查看这里-->),这样我也可以设置时间

这是我的html:

<angular2-date-picker [(ngModel)]="fromDate" [settings]="settings"></angular2-date-picker>
然后,我想将变量
fromDate
转换为时间戳格式;我试过使用这个,但不起作用:

Math.floor(this.fromDate.getTime() / 1000).toString();
在控制台中,它向我显示了这个错误

'fromDate.getDate is not a function ... ...'

是否有其他方法获取时间戳?

尝试
date:date=new date()
或者fromDate属性似乎包含一个字符串,而不是一个日期对象,您可以使用日期对其进行测试,例如:
newdate('2017-03-08T00:00:00+01:00')

'fromDate.getDate is not a function ... ...'