06.07.2017 Views

Mastering JavaScript

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>JavaScript</strong> Primer<br />

Here are some examples on how to create and manipulate dates in <strong>JavaScript</strong>:<br />

var today = new Date();<br />

console.log(today.getDate()); //27<br />

console.log(today.getMonth()); //4<br />

console.log(today.getFullYear()); //2015<br />

console.log(today.getHours()); //23<br />

console.log(today.getMinutes()); //13<br />

console.log(today.getSeconds()); //10<br />

//number of milliseconds since January 1, 1970, 00:00:00 UTC<br />

console.log(today.getTime()); //1432748611392<br />

console.log(today.getTimezoneOffset()); //-330 Minutes<br />

//Calculating elapsed time<br />

var start = Date.now();<br />

// loop for a long time<br />

for (var i=0;i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!