ReadLine ; } } Output: Conclusion In C , a string can be converted to DateTime object using parsing methods provided by DateTime struct.
There are a number of methods available to convert a string to date in C.
The dates and times you receive back may not always be in a datetime format.
Caution: The precision of subsecond values is limited to what is supported for the time field data type, for example, if using a time field of field data type float or double, rounding errors should be expected.
In the newer way, dates have their own format and parse methods and use a DateTimeFormatter simply for the pattern.
You can combine pretty much any number of formats using the available patterns.