如何将日期的"时间"部分返回为人性化字符串。
htmljavascriptprogramming scripts更新于 2024/6/4 5:00:17
要将日期的"时间"部分返回为人性化字符串,请使用 JavaScript 中的 toTimeString() 方法。此方法以人性化格式返回日期对象的时间部分。
示例
您需要运行以下代码才能仅返回日期的时间部分 −
<html> <head> <title>JavaScript toTimeString Method</title> </head> <body> <script> var dateobject = new Date(2018, 0, 1, 14, 39, 7); document.write( dateobject.toTimeString() ); </script> </body> </html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

