Reputation: 83
I do not understand why the timestamp from my code is always off by 3 minutes...What am I missing/doing wrong? I know I can add minutes to the timestamp but I want the timestamp to always be as accurate as possible to the computer's time without having to periodically add to the minutes in the code. Also, if I kept my code like this, would it change automatically when Daylight Saving Time ends and starts? Thanks in advance.
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
date_default_timezone_set("America/New_York");
echo date("Y/m/d h:i:s a");
?>
Upvotes: 0
Views: 973
Reputation: 4159
I'm assuming you have a server that is hosting your PHP and you are comparing it's time against your personal computer. Time between the server and user's computer will vary, just like every clock will vary slightly.
As far as daylight savings and timezones, see php date and daylight savings time confusion. In short, PHP understands timezones and all of their nuances, so it will provide the correct time based on the location/timezone.
Upvotes: 2