Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2007, 12:36 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default please help

How to convert indian time in to other timings by taking dropdownlist (countries),and to get time of that particular country in textbox .pls help me

 
Old May 4th, 2007, 07:08 AM
Authorized User
 
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

You need to get the locale of the country you are wanting to convert to.

Have a look at the CultureInfo class to do this.

All cultures have a country/region setup, so you need to have specific knowledge of what region you are formatting for.

Here is an example of getting all of the specific regions (as you can't format general ones), and printing out the date format.

Code:
DateTime now = DateTime.Now;
foreach(CultureInfo currentCulture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
     string countryName = currentCulture.EnglishName;
     string cultureCode = currentCulture.Name;
     IFormatProvider dateFormat = currentCulture.DateTimeFormat
     Console.WriteLine("{0} ({1}): {2}", countryName, cultureCode, now.ToString(dateFormat));
}
There are other formats like CalendarFormat and NumberFormat. Refer to the documentation for more advanced examples.

Hope this helps,

Dominic









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.