Hello All,

I have a requirement let me know if it is possible. There will be a
web application which will be accessed by users from different
countries. No matter where the user is accessing from I will be saving
the dates in utc format as an example

strSQL = "Insert into emp(joindate)values
('"+DateTime.Now.ToUniversalTime()+"');";
Now at the time of retrieving the dates I have to show the dates
depending on the timezone of the user accessing the web page.
For that I have used the following code segment

Response.Write(Convert.ToDateTime(reader["joindate"].ToString
(),Thread.CurrentThread.CurrentCulture.DateTimeFormat) + "<br>");

Following is the code segment which I have have used in the
Global.asax.cs Application_BeginRequest to retrieve the first language
from browser language list.

HttpRequest request = HttpContext.Current.Request;
            if (request.UserLanguages == null) return;
            string language = request.UserLanguages[0];
            if (language != null)
            {
                if (language.Length < 3)
                {
                    language = language + "-" + language.ToUpper();
                }
                Thread.CurrentThread.CurrentUICulture = new CultureInfo
(language);
                Thread.CurrentThread.CurrentCulture = new CultureInfo
(language);
            }
I have added new language from languages add option (internet
explorer) for example French (France) [fr-FR]. Now when the date is
rendering it is formatted with the code page, but is there any way to
automatically increment /decrement the date time detecting the
timezone the user is accessing the web page? One way it could be done
I can explicitly mention the time zone and add / subtract the time
difference.

Please let me know if you have any hint.

Reply via email to