avaScript Get the current timestamp : 
The first method :

Copy the code as follows :
var timestamp = Date.parse(new Date()); 

result :1280977330000 
The second method :

Copy the code as follows :
var timestamp = (new Date()).valueOf(); 

result :1280977330748

The above code will be obtained from 1970 year 1 month 1 The number of milliseconds that start at midnight on Sunday . The difference between them is , The millisecond bit of the first method is all zero , It's just milliseconds to the second

As shown in the title , return unix The specific time corresponding to the timestamp :

Copy the code as follows :
var time = '1278927966'; 
// The key is riding 1000, Because time is relative to 1970 Year begins , So by 1000 After that, it will go to the current time . 
var real_time = new Date(time) * 1000; 
document.write(real_time); 

The code is very simple to complete the time stamp conversion .

javascript Use in new Date().getTime() Method

IE8 The above version can be used Use it directly Date.now() Method

//IE8 The following versions
if (!Date.now) {
    Date.now = function() { return new Date().getTime(); };
}

jQuery Get the timestamp $.now()

var timestamp = $.now();

The following is the supplement of other netizens :

JavaScript Get the current timestamp :

The first method :

var timestamp = Date.parse(new Date());

result :1280977330000
The second method :

var timestamp = (new Date()).valueOf();

result :1280977330748

The third method :

var timestamp=new Date().getTime();
result :1280977330748

The first one is : The obtained timestamp is changed from MS to Ms 000 Show ,
The second way is to get the current time stamp and the third way is to get the current time stamp .

JavaScript Get more articles about the code for the current timestamp

  1. Javascript How to get the current timestamp

    Define date :   Date Object is used to process date and time .   Can pass new  Key words to define Date object . The following code defines a code named myDate Of Date object :   var myDate=new Dat ...

  2. JavaScript Get the current timestamp

    From the blog (http://blog.sina.com.cn/s/blog_8772845101019kg5.html) JavaScript Get the current timestamp : The first method : var timestamp = ...

  3. C#、Java、Javascript obtain Unix Time stamp

    background : Because the project needs , Need several languages linkage development , Digital type of date field design obtain Unix Time stamp code : Java System.currentTimeMillis() Javascript new Date(). ...

  4. javascript Get the code of the corresponding page

    window.onload = function () { function getUrls(url) {// The core code is url2 This line of code , adopt .replace() Method to replace the corresponding string with another method va ...

  5. A simple javascript obtain URL The code of the parameter

    function request(paras){ var url = location.href; var paraString = url.substring(url.indexOf("? ...

  6. javascript Get the current timestamp

    JavaScript Get the current timestamp : The first method : var timestamp = Date.parse(new Date()); result :1280977330000 The second method : var timesta ...

  7. javascript Get the timestamp

    Time stamp : The time stamp is from 1970 year 1 month 1 Japan (00:00:00 GMT) Seconds since . It's also called Unix Time stamp (Unix Timestamp). JavaScript Get the current timestamp : < ...

  8. [javascript]JS How to get the current timestamp

    [javascript]JS How to get the current timestamp One . summary One sentence summary :var timestamp = Date.parse(new Date()); The result is a three bit millisecond , Divide by one more 1000 Just round it up 1.j ...

  9. [javascript]JS How to get the current timestamp

    JavaScript Get the current timestamp : The first method :( This method is only accurate to seconds ) var timestamp = Date.parse(new Date()); result :1280977330000 The second method ...

Random recommendation

  1. Cach&#233; Database learning notes (5)

    Catalog Cache The development of database method RESTful encapsulation ================================================================ Because of web serv ...

  2. laravel The log is daily How to set the maximum number of days to save

    stay laravel in , The log is set to daily when , The default is to save the log for seven days , More than seven days before the log will be cleared . You can modify the default settings , If you want to keep it 30 Day's diary , The configuration is as follows : In profile config/app.php Add the following code to : ...

  3. iOS - Swift NSSize Size

    Preface Structure , This structure is used to represent the width and height of things . public typealias NSSize = CGSize public struct CGSize { public var width: ...

  4. HDU1312-Red and Black-DFS

    Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. My blog address and github Address

    Blog address  http://www.cnblogs.com/sjzsjzsjz/ github Address   https://github.com/sjzsjzsjz

  6. Office - Outlook

    Save mail locally Limited server capacity , Avoid loss and often prompt for insufficient capacity step stay File->Account Settings->Account Settings below stay Data Files New tab ...

  7. Eigen learning Array class

    Eigen Not only Matrix and Vector structure , It also provides Array structure . The difference between the following ,Matrix and Vector The matrix and vector defined in linear algebra , *** . But there is a problem with mathematics ...

  8. kalilinux System settings

    echo LANG="zh_CN.UTF-8" > /etc/default/locale

  9. Linux in redis Installation and configuration

    redis Official website address :http://www.redis.io/ redis install stay Linux Lower installation Redis It's simple , Here we use 2.8.3 Version as an example , The specific steps are as follows : 1. Download the source code , Decompress and compile the source code . $ mk ...

  10. java The three framework SSH(Struts2 Spring Hibernate)

    http://www.cnblogs.com/qiuzhongyang/p/3874149.html