0

this is my requirement.website admin add a time to an event. Then users will see that time according to user's current location time.

And this php code to convert any time to user current location's time.

<?php
    $date = date_create('2000-01-01',timezone_open('Pacific/Nauru'));
    date_timezone_set($date,timezone_open('Europe/Moscow'));
    echo date_format($date, 'Y-m-d H:i:sP') . "\n";
?>

How to determine user timezone (ex:Europe/Moscow)

I have this js code to get timezone of user current location.

<script>
    var visitortime = new Date();
    var time = visitortime.getTimezoneOffset()/60;
    alert(time);
</script>

But it alert a number(ex:+5.5) Can you help me please

Ravi Sachaniya
  • 1,641
  • 18
  • 20
Dils Umesha
  • 37
  • 1
  • 7

1 Answers1

2

Use this code to get current users timezone.

var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
Aslam Patel
  • 874
  • 6
  • 19