Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two ways to do this.</p> <ul> <li><p>Indeed, you can use javascript to fetch their current time/timezone. There is the possibility that the user's computer time is not set correctly, in which case the time zone you display will not be correct.</p> <p>Because you are using Rails, a recommended way is to get javascript already bundled as a gem, like <a href="https://github.com/scottwater/detect_timezone_rails" rel="noreferrer"><code>detect_timezone_rails</code></a>. This makes it easy to install (because it is all bundled automatically in the asset pipeline.</p></li> <li><p>You can use the IP address to infer their country and time zone. The danger in this case is that a user may be using a proxy. Also, while the IP address generally has city-level resolution, it may be more or less accurate, which may in rare cases give the wrong time zone.</p> <p>Using the IP address, you can get their approximate city and latitude/longitude. There are many gems that can do this on <a href="https://www.ruby-toolbox.com/categories/geocoding___maps" rel="noreferrer">Ruby Toolbox</a>, eg. <a href="https://github.com/alexreisner/geocoder" rel="noreferrer"><code>geocoder</code></a>. With the latitude/longitude, you can get the time zone using a gem like <a href="https://github.com/panthomakos/timezone" rel="noreferrer"><code>timezone</code></a>.</p></li> </ul> <p>You can also use one of the above, and allow the user to manually change their time zone on your website (either storing this setting in a database if registered, or as a cookie on their browser). This is useful in case you got the timezone wrong.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload