這篇文章主要介紹了JavaScript中Date.toSource()方法的使用教程,用來返回日期為字符串,是JS入門學習中的基礎知識,需要的朋友可以參考下
此方法返回表示對象的源代碼的字符串。
注:此方法可能不會在類IE的所有瀏覽器上正常工作。
語法
- Date.toSource()
下面是參數的詳細信息:
NA
返回值:
對于內置日期對象,toSource返回字符串string (new Date(...))表示該源代碼不可用
對于日期的實例,toSource返回表示源代碼的字符串。
例子:
- <html>
- <head>
- <title>JavaScript toSource Method</title>
- </head>
- <body>
- <script type="text/javascript">
- var dt = new Date(1993, 6, 28, 14, 39, 7);
- document.write( "Formated Date : " + dt.toSource() );
- </script>
- </body>
- </html>
這將產生以下結果:
- Formated Date : (new Date(743850547000))
新聞熱點
疑難解答
圖片精選