Created
July 10, 2017 03:37
-
-
Save roylee0704/99f38f3ef2c7c716a4e7bf1149d83bb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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