我试图以这种格式获取当前日期和明天的日期以及yesteday的日期 2015-05-21
我已经使这些功能运行得很好,但我想了解你的观点,我不是javascript专家,所以我想确保它能在我的应用程序上正常运行.
function gettodaydate() {
var d = new Date();
var date=""+d.getFullYear()+"-"+d.getMonth()+"-"+d.getDate();
return date;
}
function gettomorrowdate() {
var d = new Date();
var date=""+d.getFullYear()+"-"+d.getMonth()+"-"+(d.getDate()+1);
return date;
}
function getyesterdaydate() {
var d = new Date();
var date=""+d.getFullYear()+"-"+d.getMonth()+"-"+(d.getDate()-1);
return date;
}
Run Code Online (Sandbox Code Playgroud)
Jor*_*lla 13
今天的
var currentDate = new Date();
Run Code Online (Sandbox Code Playgroud)
打印:
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
Run Code Online (Sandbox Code Playgroud)
然后......如果一天有24小时>> 60分60秒1000毫秒....
var yesterday = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
var tomorrow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23514 次 |
| 最近记录: |