• Resolved Generosus

    (@generosus)


    Good Day,

    We have created a site page that automatically displays our server’s date and time in UTC time when the page is accessed (or triggered) by a site visitor. The information is pulled from:

    WP Dashboard > Settings > General > Timezone – Date Format – Time Format

    Our Challenge:

    We would like to change the above information to display the site visitor’s date, time, and timezone (i.e., based on the visitor’s server IP address and/or geolocation).

    Details (Frontend): https://prnt.sc/isP4w0sp8pIp
    Details (Backend): https://prnt.sc/-KFMb9_BHYyW

    Request:

    1. Is there any way your plugin can help us accomplish the above?
    2. We’re using this code snippet to generate a shortcode that can be placed on any page location to display our server’s date, time, and timezone. Would you know how to modify it in order to use your plugin’s features? (i.e., display visitor’s date, time, and timezone instead).

    Notes:

    1. We installed and activated your plugin but,”out of the box”, it did not help.
    2. If the above is doable, kindly provide step-by-step instructions to incorporate your solution.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Generosus

    (@generosus)

    Update:

    Issue solved!

    Solution:

    1. Download this plugin to your desktop.
    2. Unzip the plugin and move the file “use-clients-timezone.php” to your desktop.
    3. Upload the file “use-clients-timezone.php” to the folder: /wp-content/plugins
    4. Upload and activate this plugin.
    5. Set the plugin’s fallback time zone to “UTC
    6. Add this code snippet to your functions.php file (directly or via the Code Snippets plugin).
    7. Add the following shortcode to any page of your website: [date-today format='F j, Y g:i A T']
    8. Clear all cache.
    9. That’s it!

    Testing:

    1. Test the page containing your shortcode using this online test tool. Enter your affected page URL and desired Country.
    2. Compare the date, time, and timezone displayed in the test performed per 1. above with the information displayed here. (Note: Enter the same city and country displayed in the online test tool). They should match.

    Results:

    Local Date, Time, and Time Zone (Fallback timezone shown when local timezone not detected).

    Thread Starter Generosus

    (@generosus)

    Update:

    Disregard Solution Steps 1. to 3. above. Else works great ??

    Plugin Author drmikegreen

    (@drmikegreen)

    Using my plugin for this is a bit of going “round Robin Hood’s barn,” since the plugin uses JavaScript to get the user’s time information. A simpler solution is to use one of the solutions at https://www.w3schools.com/js/js_dates.asp, e.g., which just use JavaScript directly.

    But I’m glad that you’re using the plugin and have found a way to get it to so what you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Display Visitor’s Date, Time, and Timezone’ is closed to new replies.