I have a module in my website where logged in users can post comments on any article. I am saving UTC time
as posted time in database. As per my requirement I need to display posted time
for comment and the time difference
between posted time and current time (for example last seen in Facebook or comment posted time in Facebook) with the comment. The posted time must show in Client Browser's timezone
.
For e.g: User XYZ has commented on 01:00 UTC
, and
If account of XYZ is logged in from India then
timezone
must beIndia Time Zone (UTC+05:30)
and time will appear 6:30 AM.If account of XYZ is logged in from Singapore then timezone must be
Singapore Time Zone(UTC+8:00)
and time will appear 9:00 AM.
To achieve above I have searched on web and found this post get client time zone from browser which was very helpful to get client browser's timezone
. (Which I am not able to test yet if it will convert the time correctly or not)
Now the main issue is to convert UTC time to given timezone
(which I am getting using solution mentioned here get client time zone from browser).
Please share suggestions.