Skip to content

Instantly share code, notes, and snippets.

@roylee0704
Created July 10, 2017 03:37
Show Gist options
  • Save roylee0704/99f38f3ef2c7c716a4e7bf1149d83bb8 to your computer and use it in GitHub Desktop.
Save roylee0704/99f38f3ef2c7c716a4e7bf1149d83bb8 to your computer and use it in GitHub Desktop.
const now = new Date();
const utcNow = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
// A js Date object stores 2 primitive values: x and tz, based on y. For instance: new Date(y); IF y = NULL, y = machine time.
// - y = machine time (x + tz)
// - tz = machine tz. i.e: +8
// - console.log(now.toString()) returns (x + tz);
// - console.log(now) returns x;
console.log(now); // +0
console.log(now.toString()); // +8
console.log(utcNow); // utcNow.x-8 = now.x
console.log(utcNow.toString()); //
//// what did JavaScripts Date object uses to compare? x.
console.log(now > utcNow);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment