Combine date format with DateTimeFormatInfo.InvariantInfo
Option Explicit
Option Strict
Imports System
Imports System.Globalization
Public Class MainClass
Public Shared Sub Main()
Dim dt As DateTime = DateTime.Now
Dim myformat() As String = {"d", "D", _
"f", "F", _
"g", "G", _
"m", _
"r", _
"s", _
"t", "T", _
"u", "U", _
"y", _
"dddd, MMMM dd yyyy", _
"ddd, MMM d ""'""yy", _
"dddd, MMMM dd", _
"M/yy", _
"dd-MM-yy"}
Dim mydate As String
Dim i As Integer
For i = 0 To myformat.Length - 1
mydate = dt.ToString(myformat(i), DateTimeFormatInfo.InvariantInfo)
Console.WriteLine(String.Concat(myformat(i), " :", mydate))
Next i
End Sub
End Class
Related examples in the same category
1. | Date time: Now, Today and UTC Now | | |
2. | Date Time Detail: Long Date String, day of week, days in month | | |
3. | Is Leap Year | | |
4. | Get Date Time Now | | |
5. | Display 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. | Add two and a half hours to DateTimeOffset | | |
12. | Convert DateTimeOffset to Universal Time | | |
13. | DateTime - DateTime = TimeSpan | | |
14. | DateTime.ParseExact Converts string to DateTime using specified format, culture-specific format information, and style | | |
15. | DateTime.Subtract subtracts the specified date and time from this instance. | | |
16. | DateTime.Ticks represents the number of ticks that represent the date and time | | |
17. | DateTime.Today Property Gets the current date. | | |
18. | DateTime.ToFileTime Method converts DateTime to a Windows file time. | | |
19. | DateTime.ToLocalTime Method converts DateTime object to local time. | | |
20. | DateTime Kind, Now properties, and the SpecifyKind(), ToLocalTime(), and ToUniversalTime() methods. | | |
21. | DateTime.ToLongDateString converts DateTime to long date string | | |
22. | Converts the value of the current DateTime object to its equivalent short date string representation. | | |
23. | DateTime.ToString Method converts DateTime to string using the specified culture-specific format information. | | |
24. | DateTime.ToString converts DateTime to string using the specified format. | | |
25. | Converts DateTime to string using the specified format and culture-specific format information. | | |
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 | | |