diff --git a/README.md b/README.md index 4bb23dd..735488d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_967 TILs and counting..._ +_968 TILs and counting..._ --- @@ -365,6 +365,7 @@ _967 TILs and counting..._ - [Sorting Arrays Of Objects With Lodash](javascript/sorting-arrays-of-objects-with-lodash.md) - [Splat Arguments To A Function](javascript/splat-arguments-to-a-function.md) - [Spread The Rest With ES6](javascript/spread-the-rest-with-es6.md) +- [Start Node Process In Specific Timezone](javascript/start-node-process-in-specific-timezone.md) - [String Interpolation With Template Literals](javascript/string-interpolation-with-template-literals.md) - [Support Nested Matching In Custom Jest Matchers](javascript/support-nested-matching-in-custom-jest-matchers.md) - [Test Coverage Stats With Jest](javascript/test-coverage-stats-with-jest.md) diff --git a/javascript/start-node-process-in-specific-timezone.md b/javascript/start-node-process-in-specific-timezone.md new file mode 100644 index 0000000..de57306 --- /dev/null +++ b/javascript/start-node-process-in-specific-timezone.md @@ -0,0 +1,35 @@ +# Start Node Process In Specific Timezone + +When running a node process on your machine locally, it will adopt your +machine's local timezone. + +I can observe this by starting a `node` process and outputting a date with +`toLocaleString()`. + +```javascript +> new Date().toLocaleString() +'11/30/2020, 8:48:17 PM' +``` + +This is the time that I'm writing this post, in Chicago (CST). + +I can then start the process in another timezone, such as UTC. + +```bash +$ TZ=utc node +``` + +With that `node` process, I can now do the same experiment. + +```javascript +> new Date().toLocaleString() +'12/1/2020, 2:52:40 AM' +``` + +The time jumps ahead about 6 hours because it is going from CST (UTC-6) to UTC. + +Similarly, I could start the Node process for the west coast like so, + +```bash +$ TZ='America/Los_Angeles' node +```