Ways to know time/date from user's point of view? (From different time zones)

Hey all!

I have an admij page which shows users’ actions with a field for their date/time

I went abroad and noticed that I see these fields now from my new time zone and not with the users’ time

My goal is to see on the admin page for each action the time it occurred from the user’s perspective in his own time zone

Not sure how to approach this. Any thoughts

Thanks!

You can have timezone set to current user or current data

1 Like

To do that you’d have to store the User’s time zone on the related database object, and then use that time zone when displaying the date/time.

Or better still, just store and display all dates/time in a fixed time zone (i.e. UTC).

Thanks! @adamhholmes That does sound like the solution I was looking for.

About storing it with UTC, how is that being done? Is it different than just storing “current date/time”?

Actually… having re-read your initial post… I’m not sure that is a good idea here…

Unless you want to duplicate the timestamps (i.e. keep the original timestamp, and also have a duplicate field to convert the timestamp into the same time in UTC… you’ll need a plugin or some custom JS to do that though), so you don’t lose the original timestamp.

You’re probably better off using the User’s actual time zone to display the times on your admin page - so you’ll need to store the User’s time zone somewhere in the database and access that.

1 Like

Got it, Thanks that helps a lot

1 Like

Hey @siddharth what do you mean by setting the timezone to current data?

Hey there!

This is a common challenge when managing a website or app with users across different time zones. Here are a couple of approaches to consider, and depending on your specific admin panel setup, one might be more suitable:

  1. Server-Side Time Zone Conversion:
  • Ideally, your admin panel should store the user’s time zone information along with their actions.
  • When displaying timestamps on the admin page, the server can then convert the stored UTC timestamp (universal coordinated time) to the user’s preferred time zone before displaying it.
  • This ensures you see the action time from the user’s perspective.This approach might require some development work on your admin panel’s backend.
  1. Client-Side Time Zone Adjustment (Potential Solution):
  • If server-side conversion isn’t feasible, you could explore client-side adjustments.
  • This might involve adding a user setting for their preferred time zone within the admin panel.
  • When the admin page loads, a script could then calculate the time difference between the server’s time zone and the user’s selected zone and adjust the displayed timestamps accordingly.

btw, check this tool for time zone conversions and calculations, which could be useful for understanding time zone differences

1 Like

Thanks! I will give it a shot!