diff --git a/README.md b/README.md index 635fb27..35cb565 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_708 TILs and counting..._ +_709 TILs and counting..._ --- @@ -249,6 +249,7 @@ _708 TILs and counting..._ - [Fill An Input With A Ton Of Text](javascript/fill-an-input-with-a-ton-of-text.md) - [Freeze An Object, Sorta](javascript/freeze-an-object-sorta.md) - [Get The Location And Size Of An Element](javascript/get-the-location-and-size-of-an-element.md) +- [Get The Time Zone Of The Client Computer](javascript/get-the-time-zone-of-the-client-computer.md) - [Globally Install A Package With Yarn](javascript/globally-install-a-package-with-yarn.md) - [Immutable Remove With The Spread Operator](javascript/immutable-remove-with-the-spread-operator.md) - [Initialize A New JavaScript Project With Yarn](javascript/initialize-a-new-javascript-project-with-yarn.md) diff --git a/javascript/get-the-time-zone-of-the-client-computer.md b/javascript/get-the-time-zone-of-the-client-computer.md new file mode 100644 index 0000000..9e1d320 --- /dev/null +++ b/javascript/get-the-time-zone-of-the-client-computer.md @@ -0,0 +1,18 @@ +# Get The Time Zone Of The Client Computer + +The +[`resolvedOptions`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions) +function on `Intl.DateTimeFormat.prototype` provides a number of pieces of +information about the client computer. It includes information such as the +locale and the numbering system. It also has the time zone for that machine. + +Try running this line of JavaScript in your own browser. + +```javascript +$ Intl.DateTimeFormat().resolvedOptions().timeZone +``` + +When I run it, I get `America/Chicago`. + +You can use this within your client-side code as a way of determining in +which time zone your users are.