【问题标题】:in sharepoint 2013, .net library, or with REST, how do i get the regional settings of the current user?在 sharepoint 2013、.net 库或 REST 中,我如何获取当前用户的区域设置?
【发布时间】:2016-03-07 15:31:09
【问题描述】:

我可以轻松获取网络的区域设置,但我如何为当前用户做呢?

var regionalSettings = context.Web.RegionalSettings 有效,但context.Web.CurrentUser 上没有RegionalSettings

【问题讨论】:

    标签: .net sharepoint office365


    【解决方案1】:

    使用以下代码sn-p:

    var url = _spPageContextInfo.webAbsoluteUrl+"/_layouts/regionalsetng.aspx?Type=User";
    var lcid, cultureInfo, timeZone;
    
    $.get(url,function(data){
      $(data).find("select[name$='LCID'] option:selected").each(function(){
          lcid  = $(this).attr("value");
          cultureInfo  = $(this).text();
      });
      $(data).find("select[name$='TimeZone'] option:selected").each(function(){
        timeZone  = $(this).text();
      });
    
      alert(lcid + "::" + cultureInfo + "::" + timeZone);
    });

    更多信息: http://sympmarc.com/2014/08/20/detecting-the-current-users-regional-settings-with-jquery/

    【讨论】:

      【解决方案2】:

      我最终做了什么-

      我需要时区来处理上传后上传文件的日期。由于请求当前用户和网络的 TimeZone 对象变得非常混乱并且花费了太多时间,我决定从文件的修改属性中得出时区:

      var fileModifiedDate = uploadedFile.ListItemAllFields.Modified; 
      return Math.round(moment.utc(fileModifiedDate).diff(moment.utc(), 'hours', true));
      

      【讨论】:

        猜你喜欢
        • 2010-12-05
        • 2014-01-25
        • 1970-01-01
        • 2010-12-20
        • 1970-01-01
        • 2016-09-27
        • 2012-06-21
        • 2013-06-05
        • 2023-04-02
        相关资源
        最近更新 更多