how to write date in this format in c#
i have a date 9/27/2010 8:17:28 PM
i want to开发者_JAVA技巧 write them in this format like 27 september 2010 8:19 PM
how i can write in this format using c#
Use a custom DateTime format string:
string res = myDate.ToString("d MMMM yyyy h:mm tt", CultureInfo.InvariantCulture);
Update:
As @Jon Hanna mentions, this will format the month with title case (September
), so if you want it exactly as in your example (september
), you can add a ToLowerInvariant()
method call.
Check Custom Date and Time Format Strings on msdn.
精彩评论