0

I have this table.

+------------------+--------------+------+-----+-------------------+-
| Field            | Type         | Null | Key | Default           |
+------------------+--------------+------+-----+-------------------+-
| encoded_date     | timestamp    | NO   |     | CURRENT_TIMESTAMP |
| actual_date      | date         | NO   |     | NULL              |
+------------------+--------------+------+-----+-------------------+-

My computer's date is 5/14/2015 10:10Am.. Why is it that when I submit the form, the record being save is

Encoded Date: 2015-05-13 18:59:03
beginner
  • 2,024
  • 5
  • 43
  • 76
  • 5
    what time zone is your db server using? maybe it is different than your local time zone. or perhaps it is utc – Brino May 14 '15 at 02:13
  • 1
    check out this answer on determining the timezone: http://stackoverflow.com/a/2934271/4347337 – Brino May 14 '15 at 02:16
  • `@@global.time_zone`: SYSTEM `@@session.time_zone`:SYSTEM – beginner May 14 '15 at 02:17
  • 1
    Yes, check the time zone on your db server also the timezone configured in your php.ini file. – Darian May 14 '15 at 02:18
  • hows it hosted? does your host have hardware in a different geographical location than you - probably. –  May 14 '15 at 02:21
  • 1
    Like Brino mentioned, you may be in Japan or Australia or a timezone where local time is around 10 AM and your server may be in California (Pacific Time), as an example. Around the time of this post, Pacific time is 13-May-2015 19:21 and Perth time is 14-May-2015 10:22. [PHP Get Timezone](http://php.net/manual/en/function.date-default-timezone-get.php) and [Question 2934258 about MySQL timezone](http://stackoverflow.com/questions/2934258/how-do-i-get-the-current-time-zone-of-mysql) might help you – zedfoxus May 14 '15 at 02:25

1 Answers1

2

Try setting the timezone at the top of your form page like this:

<?php
    //set time zone
    date_default_timezone_set('America/New_York');
?>

You can find whatever timezone you are in here: http://php.net/manual/en/timezones.php

user1392897
  • 831
  • 2
  • 9
  • 25