I want post times to reflect the timezone of the logged in or logged out user on my site. So if I post at 2:43PM London time, I want a user or visitor from Tokyo to see the post time as 11:43PM

I'm using get_the_time("g:i a", $post_id) format with timezone set to UTC. Does this already happen magically or?

  • You won't be able to use page caching if you do this, and there's no guarantee you can detect what the current timezone is from PHP, if it's possible at all. A quick google suggests that for this to work you need to grab the timezone in javascript and set it in a cookie, so it won't be possible to do this on the first page load ( and there are privacy legal implications of doing so) stackoverflow.com/questions/13155886/…
    – Tom J Nowell
    Jan 6, 2020 at 16:14
  • If the user is logged in you could ask them their timezone and store it in user meta perhaps? Eitherway what you're asking for is not as simple or easy as it might appear
    – Tom J Nowell
    Jan 6, 2020 at 16:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.