Reputation: 14530
Is there a way to convert a datetime
like 1/28/2016 to Friday January 28 2016 in C#
?
I'm using .ToShortDateString()
to remove the time. I just want the date.
Upvotes: 0
Views: 5948
Reputation: 31
You can use .ToLongDateString()
instead. For example:
DateTime myDateTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
Console.WriteLine(myDateTime.ToLongDateString());
This will output "Wednesday, May 16, 2001" to the console window.
Upvotes: 3
Reputation: 381
While converting date to string you can set its format
someDate.ToString("dddd MMMM d yyyy");
should give you format you need.
.ToLongDateString()
should also work, but it doesn't give you customization capabilities.
You can find out more about date formatting here: Custom Date and Time Format Strings
Upvotes: 3
Reputation: 15407
Use the DateTime.ToLongDateString()
function, it is designed to fulfill your requirement.
Upvotes: 5