Add two and a half hours to DateTimeOffset : Date Time « Date Time « VB.Net






Add two and a half hours to DateTimeOffset

 

Module IntervalArithmetic
   Public Sub Main()
      Dim generalTime As Date = #03/09/2010 1:30AM#
      Const tzName As String = "Central Standard Time"
      Dim twoAndAHalfHours As New TimeSpan(2, 30, 0)

      Try
         Dim centralTime1 As New DateTimeOffset(generalTime,TimeZoneInfo.FindSystemTimeZoneById(tzName).GetUtcOffset(generalTime))
         
         Dim centralTime2 As DateTimeOffset = centralTime1.Add(twoAndAHalfHours)
         Console.WriteLine("{0} + {1} hours = {2}", centralTime1, _
                                                    twoAndAHalfHours.ToString(), _
                                                    centralTime2)   
      Catch e As TimeZoneNotFoundException
         Console.WriteLine("Unable to retrieve Central Standard Time zone information.")
      End Try
   End Sub
End Module

   
  








Related examples in the same category

1.Date time: Now, Today and UTC NowDate time: Now, Today and UTC Now
2.Date Time Detail: Long Date String, day of week, days in monthDate Time Detail: Long Date String, day of week, days in month
3.Is Leap YearIs Leap Year
4.Get Date Time NowGet Date Time Now
5.Display the various properties for a DateDisplay the various properties for a Date
6.Finding the Last Day of the Month
7.Assign a value according to the current day of the week.
8.DateTime.ParseExact passes a string object followed by a format specifier and a CultureInfo object
9.DateTimeOffset represents time relative to Coordinated Universal Time (UTC).
10.Find difference between Now and UtcNow using DateTimeOffset
11.Convert DateTimeOffset to Universal Time
12.DateTime - DateTime = TimeSpan
13.DateTime.ParseExact Converts string to DateTime using specified format, culture-specific format information, and style
14.DateTime.Subtract subtracts the specified date and time from this instance.
15.DateTime.Ticks represents the number of ticks that represent the date and time
16.DateTime.Today Property Gets the current date.
17.DateTime.ToFileTime Method converts DateTime to a Windows file time.
18.DateTime.ToLocalTime Method converts DateTime object to local time.
19.DateTime Kind, Now properties, and the SpecifyKind(), ToLocalTime(), and ToUniversalTime() methods.
20.DateTime.ToLongDateString converts DateTime to long date string
21.Converts the value of the current DateTime object to its equivalent short date string representation.
22.DateTime.ToString Method converts DateTime to string using the specified culture-specific format information.
23.DateTime.ToString converts DateTime to string using the specified format.
24.Converts DateTime to string using the specified format and culture-specific format information.
25.Combine date format with DateTimeFormatInfo.InvariantInfo
26.Converts DateTime to string representation.
27.Converts DateTime object to Coordinated Universal Time (UTC).
28.Converts string to DateTime equivalent and returns a value that indicates whether the conversion succeeded.
29.Converts string to DateTime using specified culture-specific format information and formatting style
30.Converts string to DateTime using specified format, culture-specific format information, and style
31.DateTime.Year Property gets the year component of the date represented by this instance.
32.DateTimeFormatInfo defines how DateTime values are formatted and displayed, depending on the culture.
33.DateTime format: D
34.DateTime format: f
35.DateTime format: F
36.DateTime format: g
37.DateTime format: G
38.DateTime format: m
39.DateTime format: M
40.DateTime format: o
41.DateTime format: r
42.DateTime format: R
43.DateTime format: s
44.DateTime format: t
45.DateTime format: T
46.DateTime format: u
47.DateTime format: U
48.DateTime format: y
49.DateTime format: Y
50.Difference Between DateTime, DateTimeOffset, and TimeZoneInfo
51.Create DateTime structure to the specified year, month, and day.
52.Create DateTime structure to the specified year, month, and day for the specified calendar.
53.Create DateTime structure to the specified year, month, day, hour, minute, and second.
54.Create DateTime structure to the specified year, month, day, hour, minute, and second for the specified calendar.
55.Create DateTime structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time.
56.Create DateTime structure to the specified year, month, day, hour, minute, second, and millisecond.
57.Create DateTime structure to the specified year, month, day, hour, minute, second, and millisecond for the specified calendar.
58.Create DateTime structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time for the specified calendar.
59.Create DateTime structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time.
60.Create DateTime structure to a specified number of ticks.
61.DateTime Min value
62.DateTime ToString with Invariant Culture
63.Add specified TimeSpan to DateTime
64.Add days to DateTime
65.Add hours to DateTime
66.Add milliseconds to DateTime
67.Compares DateTime value
68.Get date and time fields from DateTime
69.Determines whether two specified instances of DateTime are equal.
70.Returns a value indicating whether this instance is equal to the specified DateTime instance.
71.DateTime.Equals(DateTime, DateTime) Returns a value indicating whether two instances of DateTime are equal.
72.DateTime.FromBinary Deserializes a 64-bit binary value and recreates an original serialized DateTime object.
73.DateTime.FromFileTime Converts the specified Windows file time to an equivalent local time.
74.DateTime.GetDateTimeFormats
75.The largest possible value of DateTime. This field is read-only.
76.DateTime Minute Property
77.The smallest possible value of DateTime.
78.DateTime.Parse converts string to DateTime
79.Converts string to DateTime using the specified culture-specific format information.
80.Converts string to DateTime using the specified culture-specific format information and formatting style.
81.Converts string to DateTime using specified format and culture-specific format information
82.CultureInfo.DateTimeFormat