[wp-trac] [WordPress Trac] #28988: Detect Time Zones automatically at installation

WordPress Trac noreply at wordpress.org
Wed May 5 17:38:31 UTC 2021


#28988: Detect Time Zones automatically at installation
--------------------------------------+------------------------------
 Reporter:  danielmount               |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Date/Time                 |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  dev-feedback needs-patch  |     Focuses:  javascript
--------------------------------------+------------------------------

Old description:

> Currently, upon installing Wordpress, one of the steps I always take is
> to go to Settings > General > Timezone to manually set my time zone. I've
> been using Wordpress for eight years, so I know to do it and how to do
> it, and it's just a minor inconvenience. However, I have seen people new
> to this platform be confused and/or not know how to change this.
>
> Is it technologically possible to use a geolocation service to query the
> IP address of the computer installing Wordpress and automatically set
> that service's best guess as to time zone, perhaps during the setup
> process?
>
> I would envision the UI option remaining in settings, in case, for
> example, a developer in one time zone builds a site for a client in
> another. But automatic detection would be perfect for the average new
> user. It would be one more element that just works out of the box for
> those who aren't particularly tech savvy.
>
> I did some searching in Trac to see if I could find a similar ticket and
> couldn't find any.

New description:

 Currently, upon installing WordPress, one of the steps I always take is to
 go to Settings > General > Timezone to manually set my time zone. I've
 been using Wordpress for eight years, so I know to do it and how to do it,
 and it's just a minor inconvenience. However, I have seen people new to
 this platform be confused and/or not know how to change this.

 Is it technologically possible to use a geolocation service to query the
 IP address of the computer installing Wordpress and automatically set that
 service's best guess as to time zone, perhaps during the setup process?

 I would envision the UI option remaining in settings, in case, for
 example, a developer in one time zone builds a site for a client in
 another. But automatic detection would be perfect for the average new
 user. It would be one more element that just works out of the box for
 those who aren't particularly tech savvy.

 I did some searching in Trac to see if I could find a similar ticket and
 couldn't find any.

--

Comment (by georgestephanis):

 Just did some minor tinkering and here's some prototype code:



 {{{
 (function($){

         // This may need some browser support checks to make sure it's
 there --
         // https://caniuse.com/mdn-
 javascript_builtins_intl_datetimeformat_resolvedoptions_computed_timezone
         const browserTz =
 Intl.DateTimeFormat().resolvedOptions().timeZone;
         const $tzSelect = $('#timezone_string');

         if ( $tzSelect.val() !== browserTz ) {
                 $tzSelect.after( '<p>Your browser timezone is currently
 set to <code>' + browserTz + '</code> -- <a
 class="updateTzSelectToBrowser" href="#">would you like to update the
 WordPress timezone to match?</a></p>' );
                 $tzSelect.parent().find('.updateTzSelectToBrowser').on(
 'click', function(e){
                         e.preventDefault();
                         $tzSelect.val( browserTz );
 $(this).parents('p').text('Updated!').fadeOut('slow');
                 })
         }

 })(jQuery);
 }}}

 My gut feeling is it'd be easier to add here to save someone scrolling
 through the massive dropdown, but totally doable to populate via js in the
 install flow if we wanted there as well.

 Definite +1 to getting something along these lines in.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/28988#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list