Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Time webpart with daylight savings

  Asked By: Carolyn    Date: Apr 18    Category: Sharepoint    Views: 2901

What is the simplest/best way to insert a webpart that shows the
current time for whatever country the site represents? In our
organization we have a site for each office in many different
countries. We want to display the time without relying on an external
site or service like we do now, and not have to worry about daylight
savings changes. This is so you visit a site and will know what time
it is in that office. Is there a way to grab the regional settings of
a SharePoint site in a webpart to grab the time zone info? Or would
such information best be configured on a case-by-case basis?



5 Answers Found

Answer #1    Answered By: Gopal Jamakhandi     Answered On: Apr 18

One option -- create a webpart  that simply renders the current date/time. Since the webpart code runs on the server, the time  of that server will be displayed.

Answer #2    Answered By: Dameon Dejesus     Answered On: Apr 18

Why not just do it in javascript in a content editor web part:-

<div id="time"></div>


var curdate = new Date()

var hours = curdate.getHours()

var minutes = curdate.getMinutes()

document.getElementById("time").innerHTML = "Current local time  is: " + hours + ":" + minutes


Answer #3    Answered By: Tejaswani Barve     Answered On: Apr 18

your idea with the webpart  is a good one, but I haven't had much
experience making one. Still, it sounds like that's a good approach.

I thought of that but doesn't Javascipt work on the client only?
Hmm...then again clocks are synchronized online these days...maybe.
I'll try it.

Answer #4    Answered By: Harshita Padwal     Answered On: Apr 18

Just an idea. Since javascript is a client-side application, why not use ASP.NET? If this time  element is going to be a standard part of your pages, just edit the default.aspx page in your site  definition using ASP.NET? It's server-side and robust (and will be on every home page without needing to add it in since you modified the SD)...makes sense to do it that way. I haven't tried it, but if you are going to be testing out a plausible solution to this, you might give it a try.

Answer #5    Answered By: Jennifer Jones     Answered On: Apr 18

Interesting approach but does user time  zone play a factor? Does the user want to see the time local to the server or to themselves. Would a server-side ASP.NET program note the users time zone  to reflect the right time?

Didn't find what you were looking for? Find more on Time webpart with daylight savings Or get search suggestion and latest updates.