我有一个格式为"05-01-2016“的字符串,当我以chrome格式运行下面的代码时,将得到正确的输出。
var fromDate =新日期(searchOpts.RunDateFrom);
fromDate.format("yyyy-MM-dd");产出= "2016/05/01“
但是,当在js文件中执行这段代码时,我将得到以下输出
2016年5月1日星期日:00:00 GMT+0530 (印度标准时间)
我怎么才能防止这件事?我需要将"2016-05-01“格式的日期传递给solr。
发布于 2016-05-31 17:47:06
formattedDate = fromDate.getFullYear() + "-" + (fromDate.getMonth()+1) + "-" + fromDate.getDate()如果你只需要绳子
发布于 2016-05-31 18:32:49
var year = fromDate.getFullYear();
var month = fromDate.getMonth() < 10 ? '0'+ fromDate.getMonth()+1 : fromDate.getMonth()+1
var date = fromDate.getDate() < 10 ? '0'+ fromDate.getDate(): fromDate.getDate()https://stackoverflow.com/questions/37552207
复制相似问题