使用AngularJS

时间:2017-07-20 10:15:14

标签: angularjs spring-mvc

在我的应用程序中,我有3种日期格式PST,CST和EST。转换为IST时,结果日期提前1天。有什么建议吗?

3 个答案:

答案 0 :(得分:0)

@ nalyd88我的HTML是

        选择面试日期*                                                              

                                                             

                                                             

        
    <div class="col-md-2">
    <p>
    <label>Start Time<label class="text-red" style="margin-bottom: 0px;">*</label></label>
    <select class="form-control " ng-model="resume.interviewAvailability[0].from" required="required" ng-change="setEndTime(0);" style="margin-bottom: 23px;">
                <option ng-repeat="time in startDate">{{time}}</option>
    </select>
    <select class="form-control " ng-model="resume.interviewAvailability[1].from" required="required" ng-change="setEndTime(1);" style="margin-bottom: 23px;">
                    <option ng-repeat="time in startDate">{{time}}</option>
     </select>
     <select  class="form-control " ng-model="resume.interviewAvailability[2].from" required="required" ng-change="setEndTime(2);" style="margin-bottom: 23px;">
                    <option ng-repeat="time in startDate">{{time}}</option>
     </select>      
 </p>
 </div>
 <div class="col-md-2">
 <p>
 <label>End Time<label class="text-red" style="margin-bottom: 0px;">*</label></label>
     <select class="form-control " ng-model="resume.interviewAvailability[0].to" ng-change="checkInvalidEndTime(0);"  ng-disabled="resume.interviewAvailability[0].invalid" required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="time in endDate1[0]">{{time}}</option>
        </select>
    <select  class="form-control" ng-model="resume.interviewAvailability[1].to" ng-change="checkInvalidEndTime(1);" ng-disabled="resume.interviewAvailability[1].invalid" required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="time in endDate1[1]">{{time}}</option>
     </select>  
     <select class="form-control" ng-model="resume.interviewAvailability[2].to"  ng-change="checkInvalidEndTime(2);" ng-disabled="resume.interviewAvailability[2].invalid" required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="time in endDate1[2]">{{time}}</option>
     </select>              
                </p>
    </div>
    <div class="col-md-2">
 <p>
 <label >Time Zone<label class="text-red" style="margin-bottom: 0px;">*</label></label>
     <select class="form-control" ng-model="resume.interviewAvailability[0].timeZone"   required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="timeZone in timeZones">{{timeZone}}</option>
        </select>
    <select  class="form-control" ng-model="resume.interviewAvailability[1].timeZone" required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="timeZone in timeZones">{{timeZone}}</option>
     </select>  
     <select class="form-control" ng-model="resume.interviewAvailability[2].timeZone"  required="required" style="margin-bottom: 23px;">
                    <option ng-repeat="timeZone in timeZones">{{timeZone}}</option>
     </select>              
                </p>
    </div>
</div>
<div class="row" style="margin-left: 0px;margin-right: 0px;margin-bottom: 8px;margin-top: 8px;">
    <div class="col-md-3">
        <h3 class="text-left text-primary">
            Attachments 
        </h3>
    </div>

答案 1 :(得分:0)

我的控制器是 (函数(){

function applyJobController($scope,$state,openingsFactory,openingsService,$loading){
    var today=new Date();
    $scope.error="";
    $scope.dateOptions={
            "first":{
                minDate: today
            },
            "second":{
                minDate:today
            },
            "third":{
                minDate: today
            }
          };

     $scope.disabled = function(date, mode) {
            return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
          };

          $scope.timeZones=["PST","CST","EST"];
            $scope.startDate=["8:30 AM","9:00 AM","9:30 AM","10:00 AM","10:30 AM","11:00 AM","11:30 AM","12:00 PM","12:30 PM","01:00 PM","01:30 PM","02:00 PM","02:30 PM","03:00 PM","03:30 PM","04:00 PM","04:30 PM","05:00 PM","05:30 PM","06:00 PM","06:30 PM","07:00 PM"];
            $scope.endDate=["9:30 AM","10:00 AM","10:30 AM","11:00 AM","11:30 AM","12:00 PM","12:30 PM","01:00 PM","01:30 PM","02:00 PM","02:30 PM","03:00 PM","03:30 PM","04:00 PM","04:30 PM","05:00 PM","05:30 PM","06:00 PM","06:30 PM","07:00 PM","07:30 PM","08:00 PM"];


    $scope.resume={
            "sections":[],
            "interviewAvailability":[
                                     {"from":$scope.startDate[0],
                                      "to":$scope.endDate[0],
                                      "timeZone":$scope.timeZones[0],
                                      "invalid":false
                                     },
                                     {"from":$scope.startDate[0],
                                          "to":$scope.endDate[0],
                                          "timeZone":$scope.timeZones[0],
                                          "invalid":false
                                      },
                                     {"from":$scope.startDate[0],
                                          "to":$scope.endDate[0],
                                          "timeZone":$scope.timeZones[0],
                                          "invalid":false
                                      }],
            "attachment":"",
            "attachmentName":"",
            "notes":""
    };

  $scope.setEndTime=function(index){
        $scope.resume.interviewAvailability[index].invalid=true;
        if($scope.resume.interviewAvailability[index].from!=="Start Time"){
            $scope.resume.interviewAvailability[index].invalid=false;
            $scope.endDate1[index]=angular.copy($scope.endDate).splice($scope.startDate.indexOf($scope.resume.interviewAvailability[index].from));
            $scope.resume.interviewAvailability[index].to=$scope.endDate1[index][0];
        }

    };

    $scope.checkInvalidEndTime=function(index){
        if($scope.resume.interviewAvailability[index].to==="End Time"){
            $scope.resume.interviewAvailability[index].invalid=true;
        }
    };

};

applyJobController.$inject=['$scope','$state','openingsFactory','openingsService','$loading'];

angular.module('vResume.openings').controller("applyJobController",applyJobController);

})();

答案 2 :(得分:0)

我将以一般性建议回答这个问题。时刻是一个很好地处理日期的工具。

注意:在您的时区午夜(如果您没有指定时间)可能只是前一天在另一个时区。可能是这样的事情会导致你的问题。