0

My questions are:

  • What is exactly unix epoch timestamp ?
  • How can i use it in PHP to convert ?
  • How can i convert base on client timezone ?

I tried many samples to get client timezone:

But I had no chance.

I tried this at last to get client timezone but no chance again :

 <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function(){
  var tz = jstz.determine(); // Determines the time zone of the browser    client
  var timezone = tz.name(); //'Asia/Kolhata' for Indian Time.
  $.post("url-to-function-that-handles-time-zone", {tz: timezone}, function(data) {
      //Preocess the timezone in the controller function and get
      //the confirmation value here. On success, refresh the page.
  });
  });
  </script>
Bharata
  • 13,509
  • 6
  • 36
  • 50

1 Answers1

0

According to the link https://www.epochconverter.com

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for 'Unix time'.

You can use The function date_default_timezone_set in order to set the client time zone, then you can call date() function to get the current time.

Bharata
  • 13,509
  • 6
  • 36
  • 50
catanha85
  • 36
  • 4