How to get server current date and time in JQuery?
My server time is in UK..
and we use in the system in India i get current date and time in JQuery it display India time.
But I want UK time in JQuery
How to get server current date and time in JQuery?
My server time is in UK..
and we use in the system in India i get current date and time in JQuery it display India time.
But I want UK time in JQuery
The getTimezoneOffset() method returns the time difference between UTC time and local time, in minutes.
and also with the help of this question, your answer will be this
var d = new Date();
var n = d.getTimezoneOffset();
var ans = new Date(d.getTime() + n * 60 * 1000);
console.log(ans.getHours()+':'+ans.getMinutes()+':'+ans.getSeconds());
In JavaScript you can get the current date and time using the Date object
var now = new Date();
in php this code return server
<? echo '{serverTime: new Date(' . time()*1000 .')}';?>
or test this code
var myVar = setInterval(myTimer, 1000);
function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}
<!DOCTYPE html>
<html>
<body>
<p>A script on this page starts this clock:</p>
<p id="demo"></p>
</body>
</html>