Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For Net 2.0 and 1.1 you could use the TimeZone class which has now been replaced by the TimeZoneInfo class.</p> <p><strong><em>Edit after further research</em></strong> It would appear that prior to NET 3.5 all that was available was the TimeZone class. It is not possible to calculate the TimeDate value for timezones other than the local one and UTC. So if you wish to calculate the time as EST or PST and you're based in the UK then things become a little more difficult.</p> <p>Here's a short demo program for using TimeZone (its from a basic console app.:</p> <pre><code>class Program { static void Main(string[] args) { DateTime time = DateTime.UtcNow; Console.WriteLine(string.Format("UTC time is {0}", time.ToShortTimeString())); TimeZone zone = TimeZone.CurrentTimeZone; //The following line depends on a call to TimeZone.GetUtcOffset for NET 1.0 and 1.1 DateTime workingTime = zone.ToLocalTime(time); DisplayTime(workingTime, zone); IFormatProvider culture = new System.Globalization.CultureInfo("en-GB", true); workingTime = DateTime.Parse("22/2/2010 12:15:32"); Console.WriteLine(); Console.WriteLine(string.Format("Historical Date Time is : {0}",workingTime.ToString())); DisplayTime(workingTime, zone); Console.WriteLine("Press any key to close ..."); Console.ReadLine(); } static void DisplayTime(DateTime time, TimeZone zone) { Console.WriteLine(string.Format("Current time zone is {0}", zone.StandardName)); Console.WriteLine(string.Format("Does this time include Daylight saving? - {0}", zone.IsDaylightSavingTime(time) ? "Yes" : "No")); if (zone.IsDaylightSavingTime(time)) { Console.WriteLine(string.Format("So this time locally is {0} {1}", time.ToShortTimeString(), zone.DaylightName)); } else { Console.WriteLine(string.Format("So this time locally is {0} {1}", time.ToShortTimeString(), zone.StandardName)); } Console.WriteLine(string.Format("Time offset from UTC is {0} hours.", zone.GetUtcOffset(time))); } } </code></pre> <p>As you can see it only deals with local time and UTC.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload