繁体   English   中英

Date.getTime() 不是 Typescript 中的函数

[英]Date.getTime() is not a function in Typescript

我在打字稿中有以下代码:

var period = self.getPeriod(someObject.createdTime);

//createdTime is of the type Date


getPeriod(date: Date){
  let today = new Date();
  today.getTime(); // works fine
  date.getTime(); // date.gettime() is not a function

  //rest of the code removed 

}

我究竟做错了什么? 如果我尝试在 someObject.createdTime.ToUTCString() 中传递字符串,它会抛出 createdTime.toUTCString() is not a function。

var period = self.getPeriod(new Date());

getPeriod(date: Date){
  let today = new Date();
  today.getTime(); 
  date.getTime(); 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM