Set time zone of user

Nov 14, 2012 at 8:08 PM

Hi, 

Perhaps this is the wrong group for this, but as here is a lot of SharePoint knowledge I try it. 

 

I have the following problem:

I created a site, which highly uses SPServices for all kind of tasks. The site is critical regarding the used timezones when records are created and updated. 

 

So it is important, that the users set their timezone in the regional settings. I also added a big info on the start page, that the users have to check their regional settings. 

 

But, as always, users are lazy ;-) 

 

What I would like to do is, to update the users regional settings (primary the timezone) automatically, when he/she is visiting the page. 

I googled a lot, but only found a solution which involves "real" programming, but I only have "normal" access to the site. 

 

I know how to read the users regional settings and how to get the users local settings but have several problems:

  • The timezone in SharePoint is only a string and doesn't includes daylight savings time. How can this securely be matched to the Javascript timezone info? 
  • How can I update the regional setting of a user only with Javascript? 

 

I really appreciate all possible hints and/or tips. 

 

Joerg 

Nov 15, 2012 at 7:42 PM
I don't think you will be successful at changing the user regional settings from the browser since that would require you to write "real code" as a active-x control.

But here is an idea to research: use IP geolocation.
Find out if there is a jsonp based API on the web that gives you details about the IP address the user is coming from. The goal would be for you to include JavaScript on the user's page that calls the API (which hopefully returns the IP's location and time zone) and then match that time-zone with the user's time zone. If different, then do the appropriate thing. Which could be: prompt the user to check and set the time zone. Or maybe use the timezone returned by the webservice.

I did a quick google search and there are services out there.

Good luck.

_____
Paul

Sent from mobile device.
Nov 16, 2012 at 1:37 PM

Hi,

 

as this is an internal SharePoint I have now "solved" it this way:

  • I created a list with no additional fields, so only the standard "Title".
  • When a user visits the Homepage it is checked if in this list is an entry where "Title=_spUserId", if not a new entry is created
  • Then I do an update of this record with just "Title = _spUserId WHERE Title = _spUserId"
  • Afterwards I read this record with DateInUtc=FALSE
  • The Modified-Field I transform to a Javascript-Date object, setting seconds and milliseconds to 0
  • Then I create a variable with the current date also setting seconds and milliseconds to 0
  • I compare these two dates
  • If the dates are different I display a popup with an info that the timezone has to be updated and provide the link to the "Regional Settings"

 

It is not the perfect solution because I haven't found a webservice to change the regional settings of a user directly, but better than nothing

 

 

--

Joerg

Coordinator
Nov 21, 2012 at 4:41 AM

Joerg:

Paul's right in his assessment, and I think you've done the best you can client side.

M.