How to format date and time to local system date and time format? I need to format date and time separately. Suppose date is "06/11/2013" and time is "16:00:00" now both need to be formatted to system current date format and time format (with am/pm if 12 hours mode).
问问题
116 次
2 回答
4
DateTime.ToString()
takes a string format parameter that allows you to create whatever format you want. http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
If you use DateTime.Now
to get the current date/time of the server you can then use the .ToString()
method to format your output.
于 2013-11-06T06:43:37.677 回答
1
using System.Globalization;
string date = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss tt", CultureInfo.InvariantCulture);
于 2013-11-06T06:47:03.730 回答