我如何才能找到明天和昨天angularjs [英] how can i find tomorrow and yesterday with angularjs
问题描述
我与angularJS工作,我需要找到下一个和日期的previous一天。
I'm working with angularJS and I need to find the next and the previous day of a date.
我有日期选择器
<span data-ng-model="$parent.selected_date" is-open="opened" data-show-button-bar="false" datepicker-popup show-weeks="false" starting-day="1" language="locale" datepicker-options="datepickerConfig" date-disabled="disabled(date, mode)" >
<button type="button" class="btn btn-default btn-md text-center" data-tooltip="{{ 'Interface-UserWeek-Tooltip-Datepicker' | translate }}" data-ng-click="open($event)"> <i class="glyphicon glyphicon-calendar"></i></button>
</span>
我从纳克模型($ parent.selected_date)中的数据,我需要后得到的日期和前一天(这对我实施日期禁用)。
我曾试图筛选:
I get the data from the ng-model ($parent.selected_date) and I need to get the day after and the day before (it's for implement my date-disabled). I have try to filter :
var day = $filter('date')($scope.$parent.selected_date, 'dd');
day++;
但它不工作的方式我想,当我在月底(比如我不想要找的32月,但我希望能有6月1日......)
but it doesn't work the way I want when I'm at the end of a month (for example I don't want to find the 32 May but I want to have the 1st of June...)
感谢的
推荐答案
的最好的最办法是使用moment.js。 BESTEST时库。 点击这里使用moment.js。
The bestest way would be to use moment.js . Bestest time library. click here to use moment.js.
您可以简单地使用
//previous day
moment.subtract('days',1);
//next day
moment.add('days',1);
这篇关于我如何才能找到明天和昨天angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!