Create DateTimeOffset using the specified year, month, day, hour, minute, second, and offset.
using System;
using System.Collections.ObjectModel;
public class TimeOffsets
{
public static void Main()
{
DateTime specificDate = new DateTime(2010, 6, 2, 06, 32, 00);
DateTimeOffset offsetDate = new DateTimeOffset(specificDate.Year,
specificDate.Month,
specificDate.Day,
specificDate.Hour,
specificDate.Minute,
specificDate.Second,
new TimeSpan(-5, 0, 0));
Console.WriteLine("Current time: {0}", offsetDate);
Console.WriteLine("Corresponding UTC time: {0}", offsetDate.UtcDateTime);
}
}
Related examples in the same category
1. | Create DateTimeOffset using the specified DateTime value. | | |
2. | Create DateTimeOffset using the specified DateTime value and offset. | | |
3. | Create DateTimeOffset using the specified year, month, day, hour, minute, second, millisecond, and offset of a specified calendar. | | |
4. | Create DateTimeOffset using the specified year, month, day, hour, minute, second, millisecond, and offset. | | |
5. | Create DateTimeOffset using the specified number of ticks and offset. | | |
6. | Gets hour from DateTimeOffset | |  |
7. | Gets second from DateTimeOffset | |  |
8. | Gets second from DateTimeOffset: s (second) | |  |
9. | Gets second from DateTimeOffset: ss | |  |
10. | Gets year from DateTimeOffset | | |
11. | Converts DateTimeOffset to the date and time specified by an offset value. | | |
12. | Converts DateTimeOffset to string with ToString() method | | |
13. | Converts DateTimeOffset to a DateTimeOffset value representing the Coordinated Universal Time (UTC). | | |
14. | Compare two DateTimeOffset values for equality | |  |
15. | Compare two DateTimeOffset values | |  |
16. | Compare one DateTimeOffset with another object | |  |
17. | Compare two DateTimeOffset values for time and offset | |  |
18. | Show possible time zone for a DateTimeOffset | | |
19. | Create DateTimeOffset from DateTime with TimeSpan | | |
20. | Choosing Between DateTime, DateTimeOffset, and TimeZoneInfo | | |
21. | Find difference between Date.Now and Date.UtcNow | | |
22. | Find difference between Now and UtcNow using DateTimeOffset | | |
23. | Compares two DateTimeOffset objects and indicates the order. | | |
24. | Compares current DateTimeOffset to a specified DateTimeOffset object and indicates the order. | | |
25. | Gets a DateTime value from DateTimeOffset | |  |
26. | Gets the day of the month from DateTimeOffset object. | |  |
27. | Gets the day of the week from DateTimeOffset | |  |
28. | Converts the file time to an equivalent local time. | | |
29. | Gets a DateTime value that represents the local date and time from DateTimeOffset | |  |
30. | Transition to DST in local time zone occurs on 3/11/2007 at 2:00 AM | |  |
31. | Is valid local time | |  |
32. | Is it an ambiguous time | |  |
33. | Gets millisecond from DateTimeOffset | |  |
34. | Gets minute from DateTimeOffset | |  |
35. | Gets the month from DateTimeOffset | |  |
36. | Gets current date and time with the local time's offset from Coordinated Universal Time (UTC). | |  |
37. | Gets the time's offset from Coordinated Universal Time (UTC). | |  |
38. | Assume time is local during the parse | |  |
39. | Assume time is UTC | |  |
40. | Parse and convert to UTC | |  |
41. | Gets the number of ticks from DateTimeOffset | |  |
42. | Gets the time of day from DateTimeOffset | |  |
43. | A summer UTC time vs a winter time | |  |
44. | Get current time in UTC | | |