DateTime.ToString(“MM/dd/yyyy HH:mm:ss.fff”) resulted in something like “09/14/2013 07.20.31.371”

后端 未结 6 1965
旧巷少年郎
旧巷少年郎 2020-12-22 20:08

I have a WP8 app, which will send the current time to a web service.

I get the datetime string by calling

DateTime.ToString(\"MM/dd/yyyy HH:mm:ss.ff         


        
6条回答
  •  天命终不由人
    2020-12-22 20:59

    You can use String.Format:

    DateTime d = DateTime.Now;
    string str = String.Format("{0:00}/{1:00}/{2:0000} {3:00}:{4:00}:{5:00}.{6:000}", d.Month, d.Day, d.Year, d.Hour, d.Minute, d.Second, d.Millisecond);
    // I got this result: "02/23/2015 16:42:38.234"
    

提交回复
热议问题