angularjs – 如何在角度js中设置默认时区

前端之家收集整理的这篇文章主要介绍了angularjs – 如何在角度js中设置默认时区前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在日期字段中设置默认时区偏移量(美国/芝加哥).新的Date函数添加代码中并将其正确调用HTML文件中.它正确显示日期和时间,但我想将时区默认设置为America / chicago.
控制器中的代码

<script>
    mainApp.controller('depositController',['$scope','$http','$filter',function($scope,$http,$filter) {	
          $scope.myDate = new Date();	
    }]); 	
</script>

HTML代码

<div class="col-lg-8">
  <input id="deposit_date" name="deposit_date" 
        class="form-control"       
        type="text" 
        ng-init="deposit_time=(myDate | date:'HH:mm:ss a' : '-0500')" 
        ng-model="deposit_time" 
        readonly="readonly"/>
</div>

我想显示America / Chicago(Central Standard Time)当前时间.

解决方法

你不能.这取决于浏览器设置

  • The AngularJS datetime filter uses the time zone settings of the browser.
  • The same application will show different time information depending on the time zone settings of the computer that the application is running on.
  • Neither JavaScript nor AngularJS currently supports displaying the date with a timezone specified by the developer

猜你在找的Angularjs相关文章