How to get user timezone using jquery?

前端 未结 6 2075
长发绾君心
长发绾君心 2020-11-30 11:03

I would like to get their timezone with names like \'Asia/Calcutta\' or \'Australia/Darwin\'

I have php installed on myserver and i

6条回答
  •  一向
    一向 (楼主)
    2020-11-30 11:20

    For detecting timezone offset you can use this function:

    function get_time_zone_offset( ) {
      var current_date = new Date();
      return parseInt(-current_date.getTimezoneOffset() / 60);
    }
    

    Example you can see here

提交回复
热议问题