加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 16:59:54 所属栏目:安全 来源:网络整理
导读:我想在日期字段中设置默认时区偏移量(美国/芝加哥).新的Date函数添加到代码中并将其正确调用到 HTML文件中.它正确显示日期和时间,但我想将时区默认设置为America / chicago. 控制器中的代码: script mainApp.controller('depositController',['$scope','$ht
我想在日期字段中设置默认时区偏移量(美国/芝加哥).新的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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读