我想在日期字段中设置默认时区偏移量(美国/芝加哥).新的Date函数添加到代码中并将其正确调用到
HTML文件中.它正确显示日期和时间,但我想将时区默认设置为America / chicago.
控制器中的代码:
控制器中的代码:
<script> mainApp.controller('depositController',['$scope','$http','$filter',function($scope,$http,$filter) { $scope.myDate = new Date(); }]); </script>
<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