Date formats in C#
I need to display dates in Month date,开发者_如何学C year (Ex: January 20, 2010).
Any suggestion ?
var dt = new DateTime(2010, 20, 1);
string s = dt.ToString("MMMM dd, yyyy");
See here for more info.
See this MSDN document. Contains all the information required for custom date and time format strings.
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Probably worth bookmarking it as well, I always find myself coming back to it.
Use String.Format(formatspecifier)
Custom Numeric Format Strings
Try DateField.ToString("MMMM-dd-yyyy");
精彩评论