|
Time Zone Conversion Demo
|
|
This demo converts a date/time value from one time zone to another. Dates can be
in the past, or in the future.
|
|
|
|
Select a time zone to convert from
|
|
Time Zone:
|
|
|
Date:
|
|
|
Time:
|
|
|
|
|
Select a time zone to convert to
|
|
Time Zone:
|
|
|
|
|
|
|
|
TimeZoneSource Solution for Microsoft .Net
The TimeZoneSource Solution for Microsoft .Net is ideal for applications where you have
users that work in multiple time zones. Date/Time information is typically stored
in a UTC format and must be converted properly between time zones.
Code Examples: [C#]
using TimeZoneSource;
// Fill a drop down list with time zones
List<TimeZoneSource.TimeZoneHelper.TzsInfo> zones = TimeZoneSource.TimeZoneHelper.ZoneList;
ddlTimeZones.DataSource = zones;
ddlTimeZones.DataTextField = "Name";
ddlTimeZones.DataValueField = "ID";
ddlTimeZones.DataBind();
// Convert a local date/time value to UTC
// Get User's time zone ID from data or form
int timeZoneID = 555;
// Get a utc DateTime value from data or form
DateTime utcDate = new DateTime(2010, 7, 1, 9, 0, 0, DateTimeKind.Utc)
// Convert utcDate to a Local DateTime value
DateTime localDateTime = TimeZoneSource.TimeZoneHelper.ToLocalTime(utcDate, timeZoneID);
// Convert a UTC date/time value to local
// Get User's time zone ID from data or form
int timeZoneID = 555;
// Get a local DateTime value from data or form
DateTime localDate = new DateTime(2010, 7, 1, 9, 0, 0, DateTimeKind.Local)
// Convert localDate to a UTC DateTime value
DateTime utcDateTime = TimeZoneSource.TimeZoneHelper.ToUniversalTime(localDate,
timeZoneID);
|
Namespace: TimeZoneSource
Public Class: TimeZoneHelper
Methods:
|
ZoneList
Returns a list of all time zones (based on Microsoft Windows)
USZoneList
Returns a list of the US time zones (based on Microsoft
Windows)
OlsonZoneList
Returns a list of Olson time zones
TzsInfo
Simple class defining the ID and Name of a time zone
ToLocalTime(DateTime time,
int tzsID)
ToLocalTime(DateTime time,
string olsonTimeZone)
Converts a universal time to a local time
ToUniversalTime(DateTime time,
int tzsID)
ToUniversalTime(DateTime time,
string olsonTimeZone)
Converts a local time to a universal time
ToLocalTimeFromLocalTime(DateTime time,
int fromTzsID, int
toTzsID)
ToLocalTimeFromLocalTime(DateTime time,
string fromOlsonTimeZone,
string toOlsonTimeZone)
Converts a local time to another time zone's local time
All date/time conversions use the Olson TZ Database.
|
|
|
|