如何使用通用時間轉換將日期轉換成字串?
要使用通用時間轉換將日期轉換成字串,請使用 toUTCString() 方法。使用通用時間轉換,該方法會將日期轉換成字串並返回。
示例
可以嘗試執行以下程式碼來了解如何使用 UTC 將日期轉換成字串−
<html> <head> <title>JavaScript toUTCString Method</title> </head> <body> <script> var dateobject = new Date(2018, 0, 15, 14, 39, 7); document.write( dateobject.toUTCString() ); </script> </body> </html>
廣告