One of the most required accessories web parts to SharePoint portals is “World Clock web part” and ” Exchange Rates web part”, today I’m going to show you how to implement both with your SharePoint environment.
- Adding World Clock:
First, you should know that there are dozens of free or purchased versions of this web part, but why to purchase when you can make one J
SharePoint Object Model provide us with a class library for Regional Settings which include local and global time zones, you can find it within ” Microsoft.SharePoint.dll“ under the class property ” SPRegionalSettings.GlobalTimeZones “:
- Create a new Visual Web part
- Add a Grid View control to the web part, and name it: grdWorldClock
- In the .CS file for the visual web part add the “Microsoft.SharePoint” name space
In the page load section add the following code:
void Page_Load(object sender, EventArgs e)
SPTimeZoneCollection timeZoneColl = SPRegionalSettings.GlobalTimeZones;
// Creating table
DataTable dt = new
// Adding Columns
foreach (SPTimeZone tz in timeZoneColl)
DateTime currentLocalDateTime = DateTime.Now;
DateTime currentDestDateTime = tz.UTCToLocalTime(currentLocalDateTime.ToUniversalTime());
// Adding Rows
dr = dt.NewRow();
dr[“Description”] = tz.Description.ToString();
dr[“Time Zone”] = currentDestDateTime.ToString();
// Connecting Data Source to our GridView
grdWorldClock.DataSource = dt;
- Just deploy your solution to your farm and you will see the results like below:
With some UI tweaks you can enhance the interface and make it better view, also you can make it as a dropdown list and the results changes upon click.
Also there is a fast solution using a ready made code from the well know site “Clock Link”, and here you are the link to code:
You can add it within your Embedded Code area:
Then insert the following code:
Then the result will be like that:
- Now how to add an Exchange Rates web part.
It’s very simple, just go to The Money Converter web site http://themoneyconverter.com and from the upper side select Exchange Rates, then from the table there select your currency preference, I have picked up SAR, http://themoneyconverter.com/SAR/Exchange_Rates_For_Saudi_Riyal.aspx
Then from the left side select RSS feeds which is automatically generated for SAR, http://themoneyconverter.com/rss-feed/SAR/rss.xml.
Now add an RSS Viewer web part to your desired page:
Then in the property menu add the RSS link like below:
Then after adding it the web part will load the exchange rate data for your selected currency like below:
You can also enhance the preview by tweaking UI.