how to set date and time based on users location

3.2k Views Asked by At

I want to set date and time based on users location.

I used the following php code to set the date and time in indian standard time.

how to find the users timezone.

<?php
    $timezone = "Asia/Kolkata";
    date_default_timezone_set($timezone);
    $time=date("h:i a");
    $date = date("M d,Y");
?>

thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

You need to get the timezone from a JavaScript code, and then transmit it to your server.

Examples can be found here: get user timezone