extjs获取当前时间并且怎么取7天前的时间

2025-03-29 12:16:10
推荐回答(3个)
回答(1):

很简单哦

var now = new Date(new Date()-7*24*60*60*1000);
alert(now);

这个是当前时间,我测试已经更可以弹出了。

然后再用extjs格式化一下。

var end = now.format('Y-m-d H:i:s'); 

就可以了

没有Ext.Date.format()这个函数

回答(2):

var today = new Date();
today.setDate(parseInt(today.getDate()) - 7);
console.log(today.toLocaleString());


2013年12月12日 上午10:43:03

回答(3):

 ///获取当前日期(到秒)
  var curDate = new Date()
  //格式化;
  var time=Ext.Date.format(curDate, 'Y-m-d');
  ///取7天前的时间
  var now = new Date(new Date()-7*24*60*60*1000);
  alert(now);
  或
  var today = new Date();
  today.setDate(parseInt(today.getDate()) - 7);
  console.log(today.toLocaleString());