WordPress.org

Ready to get started?Download WordPress

Forums

Getting local time (3 posts)

  1. dartiss
    Member
    Posted 2 years ago #

    Is there a simple way, within WordPress, to get the visitors local time?

    Looking at the codex, current_time('mysql') says it should but, well, doesn't - I assume when it refers to "local time" is means the administrators, as per the general settings page.

    Of course, I'm aware PHP is server side so will only return the server time, in preference to JavaScript which can provide the client side time.

    However, is there a way within, say, a WP plugin to get the visitors time?

    David.

  2. s_ha_dum
    Member
    Posted 2 years ago #

    Yeah, you are right. I don't seen anything in the current_time() function that will return "browser client local time".

    What you are trying to do seems a little tricky. It is suggested here that using javascript is the easiest way but I imagine that you could also use the client's IP address to get the right time zone (most of the time).

  3. dartiss
    Member
    Posted 2 years ago #

    Thanks for that - I think a local JS solution is going to be the best way!

    David.

Topic Closed

This topic has been closed to new replies.

About this Topic