日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

日期getTime()方法以及JavaScript中的示例

發布時間:2025/3/11 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 日期getTime()方法以及JavaScript中的示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

JavaScript Date getTime()方法 (JavaScript Date getTime() method)

getTime() method is a Date's class method and it is used to get the time in milliseconds from 1st January 1970.

getTime()方法是Date的類方法,用于獲取從1970年1月1 開始的時間(以毫秒為單位)。

It accepts nothing as the parameter and returns a total number of milliseconds from 1st January 1970 to till now.

它接受什么作為參數,并從1 1970年1月返回毫秒的總數至今。

Syntax:

句法:

var dt = new Date();dt.getTime();

Examples:

例子:

Input:var dt = new Date();dt.getTime();Output:1551709453576

JavaScript code to get the time in milliseconds using getTime() method

JavaScript代碼使用getTime()方法獲取以毫秒為單位的時間

<html> <head><title>JavaScipt Example</title></head><body> <script>var dt = new Date(); //Date constructor var timeinMs = dt.getTime(); //getting time in milliseconds//printing timedocument.write("Current time is (in milliseconds): " + timeinMs); </script> </body> </html>

Output

輸出量

Current time is (in milliseconds): 1551709453576

翻譯自: https://www.includehelp.com/code-snippets/date-getTime-method-with-example-in-javascript.aspx

總結

以上是生活随笔為你收集整理的日期getTime()方法以及JavaScript中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。