'show saved utc time in database as invisitor's local lime based on his local time zone

I have a php script that adds a time along with other data in database :

<?php 

$UTC_TIME = gmdate("Y-m-d H:i:s"); //Gives : 2022-01-26 14:11:43

?>

Now, when the webpage is viewed at different locations in different countries. So i want to display the UTC time saved in database in local time of visitor who is accessing the webpage.

For example, if a user access the page from UK, the date time (2022-01-26 14:11:43) should be into converted into UK time (That was at the time, when this data was saved into the database) and displayed.

I searched alot of topics on stackoverflow, but didn't find any working solution. Thanks for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source