Sunday, February 17, 2013

How to Display time in Different Timezones

Specific Example: How to display current time for Rio De Janeiro?

  1. Find out the timezone abbreviation or name from here http://www.timeanddate.com/worldclock/city.html?n=213
    Timezone abbreviation: BRT – Brasilia time
  2. Find out the mapping of correct standard name for the above timezone. http://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
    065E. South America Standard Time(GMT-03:00) Brasilia
  3. Now we can use the code to set timezone to E. South America Standard Time

here is the code sample.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace Timezone
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("Local time:" + DateTime.Now.ToString());

            var brazilTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time"));
            
            System.Console.WriteLine("Brazil Time:\t" + brazilTime.ToString());
            
            System.Console.ReadLine();
        }
    }
}

2 comments:

Unknown said...

Understanding how SQL Clustering works
Making sure that our configurations are correct
Granting of privileges by SQL Node to applications accessing it
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Specifying of ndb engine in the database

Unknown said...
This comment has been removed by the author.