How to convert a DateTime object to this date format:
DateTime
I am currently doing object.GetDateTimeFormats ('D') [1] .ToString ()
This gives me January 31, 2012. But I should be able to get these two things:
Use the custom DateTime formatting string:
// Returns Jan 31, 2012 myDateTimeObject.ToString("MMM dd, yyyy"); // Returns 31 January, 2012 myDateTimeObject.ToString("dd MMMM, yyyy");
All custom date and time formats are listed here.
All types of date formatting you need.
Just select the desired line format:
Console.WriteLine(DateTime.Now.ToString("d-MMM-yy"));
18-Jan-18
Console.WriteLine(DateTime.Now.ToString("d-MM-yy"));
18-1-18
Console.WriteLine(DateTime.Now.ToString("d-MM-yyyy"));
18-1-2018
Additional Information : - http://www.code-sample.net/CSharp/Format-DateTime
To get the format as - September 26, 2019
string.Format("{0:MMMM dd, yyyy}", YourDate);
Source: https://habr.com/ru/post/1393890/More articles:Wait for cursor and disable Java application - javaC # WPF text with links - c #NServiceBus "CreateBus ()" returns null - msmqselect an element with jquery that has several classes - javascript"Cannot connect to remote server" when connecting via .NET ReportingService web service call - sqlquery for null values ββin web2py DAL - web2pyDateTime format in C # - c #Range object with JSON - javascriptMrop Strophe Example - xmppHow to move a control to the center of the screen at runtime in C #? - c #All Articles