moment js取當前時間並"小時數"+1,分鐘秒數設置爲0

遇到一個需求,在angular xedittable中動態建立時間,因此想取到當前時間完整的數字,並把開始時間加1作爲結束時間:ui

- moment(new Date()).set({'minute': 00, 'second': 00}).toJSON(),
- moment(new Date()).add(1, 'H').set({'minute': 00, 'second': 00}).toJSON(),

###完整的動態增長時間行:code

$scope.addTime = function (data, start, end) {
            $log.info($rootScope.inctimeresutc);
            var uicon = 1;
            $rootScope.inserted = {
                id: $rootScope.inctimeresutc.length + 1,
                uid: current_user_id,
                uicon: uicon,
                start: moment(new Date()).set({'minute': 00, 'second': 00}).toJSON(),
                end: moment(new Date()).add(1, 'H').set({'minute': 00, 'second': 00}).toJSON(),
                mb: '0'
            };
            $rootScope.inctimeresutc.push($rootScope.inserted);
        };
相關文章
相關標籤/搜索