将日期的.getTime值转换为YYYY-MM-DD格式的日历日期

时间:2013-05-23 16:18:10

标签: javascript gettime

我正在尝试将.getTime日期/值转换回格式YYY-MM-DD。 对此有何帮助?

目前我正在使用值2013-05-23填充我的文字。这个.getTime的值是1371970800000然后我想把这个.getTime值增加1371970800001,这就是用日历格式的增量值自动填充todate字段。 对此有任何帮助非常感谢。 感谢

1 个答案:

答案 0 :(得分:1)

var selectedDate = new Date("2013-05-23").getTime();
var nextDay = new Date(selectedDate + 86400000); // 86400000 - one day in ms 

nextDay.getFullYear(); // returns year
nextDay.getMonth(); // returns month
nextDay.getDate(); // returns day

你可以做一个concat来获得所需的格式