By default, result strings reflect the formatting conventions of the en-US culture. The following table describes the custom date and time format specifiers and displays a result string produced by each format specifier. ' Unable to convert '30-12-11' to a date and time. ' Unable to convert '12-30-2011' to a date and time. ' Unable to convert '30-12-2011' to a date and time. ' The example displays the following output: DateTime thisDate1 = new DateTime(2011, 6, 10) Ĭonsole.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + ".") ĭateTimeOffset thisDate2 = new DateTimeOffset(2011, 6, 10, 15, 24, 16,Ĭonsole.WriteLine("The current date and time: ' to a date and time.", The following example illustrates both uses. In formatting operations, custom date and time format strings can be used either with the ToString method of a date and time instance or with a method that supports composite formatting. This may affect the behavior and the output of examples that illustrate the DateTime, DateTimeOffset, and TimeZoneInfo types and their members. The local time zone of the Try.NET inline code runner and playground is Coordinated Universal Time, or UTC. The modified code either runs in the interactive window or, if compilation fails, the interactive window displays all C# compiler error messages. Once you execute the code, you can modify it and run the modified code by selecting Run again. Select the Run button to run an example in an interactive window. Some of the C# examples in this article run in the Try.NET inline code runner and playground.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |