I have a script (getEpochTime.php) that is called via AJAX and gets the Epoch time of the server. I use PHP as back end so i used the time() command to get the epoch time.
getEpochEpoch.php
<?php
$serverEpoch = time();
$result = array(
'serverEpoch' => $serverEpoch
);
echo json_encode($result);
?>
Using AJAX i retrieve the server epoch time to use it for calculations:
$.ajax({
url: "js/ajax/getServerEpoch.php",
success: function(output){
var outputFromServer = jQuery.parseJSON(output);
var serverEpochTime = String(outputFromServer.serverEpoch);
console.log(serverEpochTime); // this will return the server epoch time
});
When i use this script with any browser other than IE (even Edge browser has this issue) the script works fine. When i try to use IE it returns an epoch time that is in the past; sometimes 20 seconds before, some other minutes or maybe hours. For some reason it doesn't read the actual time.
Meanwhile if i run the script in the URL of IE i get the correct epoch time.
Any advise?
Thanks!