开发者

Date formats in C#

开发者 https://www.devze.com 2022-12-30 11:22 出处:网络
I need to display dates in Month date,开发者_如何学C year (Ex: January 20, 2010). Any suggestion ?var dt = new DateTime(2010, 20, 1);

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");

0

精彩评论

暂无评论...
验证码 换一张
取 消