angularjs-计算日期加上一天 [英] angularjs - calculate a date plus one day
本文介绍了angularjs-计算日期加上一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在另一个日期之后的某一天得到日期。
我这样做:
I need to get the date one day after another date. I do :
$scope.date2.setDate($scope.date1.getDate()+1);
if
$scope.date1 = 2015-11-27
then
$scope.date2 = 2015-11-28
It s ok,
but when
$scope.date1 = 2015-12-02
then
$scope.date2 = 2015-11-28 (ie tomorrow)
我不明白为什么...
I don't understand why...
如果有人知道..
推荐答案
请尝试使用此方法效率 简单 纯JS
try this instead efficient simple pure JS
var todayDate = new Date();
console.log(new Date().setDate(todayDate.getDate()+1));
所以您将拥有相同的 Date
类型对象,因此您不需要使用 moment.js
so you will have that same Date
type object and hence you don't need to go with moment.js
这篇关于angularjs-计算日期加上一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文