I am using the .NET DateTime
type and would like to print date in the following format
"2017-08-23T11:33:14.653191-05:00"
I am currently able to get the date with year month and day by using this.
DateTime.UtcNow.ToString("yyyy-MM-dd")
The above code results in "2017-08-23", but I want the date in above format.
In C programming language, printf() function is used to print the (“character, string, float, integer, octal and hexadecimal values”) onto the output screen. We use printf() function with %d format specifier to display the value of an integer variable.
%d tells printf that the corresponding argument is to be treated as an integer value; the type of the corresponding argument must be int .
You can use a custom format string to achieve this by using DateTime Now with a format
DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.ffffffK");
Please see here. Parts of the format string are:
yyyy
is the four digit yearMM
the month (numerical)dd
the days of the monthHH
the hours (24 hours format)ss
the secondsffffff
the millionths of a second K
the time zoneIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With