Reputation: 27
i'm having a (older) mobile webpage that shows the current time in the footer of that page. Now i've added some PHP code to it, to have the user select a starting time of a working timer.
I noticed that the Javascript time is 2 minutes ahead of the PHP time.
JS :
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
document.write(hours + ":" + minutes)
PHP :
echo date('H:i');
as i said, the difference is about 2 minutes, how is that even possible? both should be server time ??
Upvotes: 0
Views: 1539
Reputation: 1390
Javacript is the time of the user...eg it may be 2 minutes if my pc time is 2 minutes ahead, or it might be difference in hours if different timezone from server!!
Php will always show server's time.
Upvotes: 1