mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Start Node Process In Specific Timezone as a javascript til
This commit is contained in:
@@ -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).
|
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)
|
- [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)
|
- [Splat Arguments To A Function](javascript/splat-arguments-to-a-function.md)
|
||||||
- [Spread The Rest With ES6](javascript/spread-the-rest-with-es6.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)
|
- [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)
|
- [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)
|
- [Test Coverage Stats With Jest](javascript/test-coverage-stats-with-jest.md)
|
||||||
|
|||||||
35
javascript/start-node-process-in-specific-timezone.md
Normal file
35
javascript/start-node-process-in-specific-timezone.md
Normal file
@@ -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
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user