I believe the clue is with it being always 9 hours difference. Couldn't it be because of the timezone setup on your system?
I checked and
PHP time() Function[
^] provides the current time as a
Unix timestamp
in GMT. (timezone independent)
I believe that would be causing it.
Quote:
The time() function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
I believe your time saved in database doesn't follow the same format. Please check and adjust your logic accordingly. Either bring both to same format (recommended) or adjust for the difference.
Refer:
PHP: time - Manual[
^]
To change timezone, example:
<?php
date_default_timezone_set("UTC");
echo "UTC:".time();
echo "<br>";
date_default_timezone_set("Europe/Helsinki");
echo "Europe/Helsinki:".time();
echo "<br>";
?>