Support » Plugins » Hacks » Getting local time

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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).

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

    David.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting local time’ is closed to new replies.