Unity DateTime格式转换

 

System.DateTime dateTime = System.DateTime.Now;

Debug.Log(dateTime.ToBinary() + "(ToBinary)");
Debug.Log(dateTime.ToFileTime() + "(ToFileTime)");
Debug.Log(dateTime.ToFileTimeUtc() + "(ToFileTimeUtc)");
Debug.Log(dateTime.ToLocalTime() + "(ToLocalTime)");
Debug.Log(dateTime.ToLongDateString() + "(ToLongDateString)");
Debug.Log(dateTime.ToLongTimeString() + "(ToLongTimeString)");
Debug.Log(dateTime.ToOADate() + "(ToOADate)");
Debug.Log(dateTime.ToShortDateString() + "(ToShortDateString)");
Debug.Log(dateTime.ToShortTimeString() + "(ToShortTimeString)");
Debug.Log(dateTime.ToString() + "(ToString)");
Debug.Log(dateTime.ToUniversalTime() + "(ToUniversalTime)");

-8586322315454550383(ToBinary)

132138489400225425(ToFileTime)

132138489400225425(ToFileTimeUtc)

2019/9/25 9:35:40(ToLocalTime)

2019年9月25日(ToLongDateString)

9:35:40(ToLongTimeString)

43733.3997687731(ToOADate)

2019/9/25(ToShortDateString)

9:35(ToShortTimeString)

2019/9/25 9:35:40(ToString)

2019/9/25 1:35:40(ToUniversalTime)

 

 Debug.Log(dateTime.ToString("yyyy-MM-dd HH:mm:ss"));

2019-09-25 09:35:40

 

DateTime详细格式转换请参考:

https://www.cnblogs.com/arxive/p/6415312.html

你可能感兴趣的:(Unity学习)