Skip to content

Instantly share code, notes, and snippets.

@momin-riyadh
Created June 10, 2017 07:57
Show Gist options
  • Select an option

  • Save momin-riyadh/16645b676946c6a45e4018f5c7f1bcc0 to your computer and use it in GitHub Desktop.

Select an option

Save momin-riyadh/16645b676946c6a45e4018f5c7f1bcc0 to your computer and use it in GitHub Desktop.
JavaScript DateTime Function
// DATE
var d1 = new Date();
console.log(d1.toTimeString());
var d2 = new Date();
console.log(d2.toDateString());
var d3 = new Date(2324344442424);
console.log(d3.toString());
var d4 = new Date("March 25 2018");
d4.setYear("2020");
console.log(d4.toString());
var startTime = new Date();
timeCount();
var endTime = new Date();
var elapsed = endTime.getTime() - startTime.getTime();
console.log(elapsed);
function timeCount() {
for (var i = 0; i < 1000000000000; i++) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment