0

I have a simple table:

id | user | start
1    11     2013-01-04 02:00:00

the start is timestamp of course.

and than I run a query that selects the row, and when I run the query threw phpmyadmin or anywhere else, it returns the result perfectly.

BUT, when my page perform a call to the server, the result is different by 1 hour difference.

Do you have any ideas?

$start = //is ok
$end   = //is ok


$query = '
            SELECT id, title, start_in, duration, color, DATE_ADD( start_in , INTERVAL (duration*60) MINUTE ) AS end_in
            FROM shifts
            WHERE start_in BETWEEN \''.$start.'\' AND \''.$end.'\'
              ';

just to clarify, I get the results in json from the server in 1 hour difference, it is before I even create nothing in js.

3
  • start doesn't look like a timestamp. It looks like a datetime. You need to show us your code. Commented Jan 2, 2013 at 16:09
  • 2
    Because your server present in different timezone. Commented Jan 2, 2013 at 16:10
  • Read this: MySQL Server Time Zone Support Commented Jan 2, 2013 at 16:11

1 Answer 1

1

If you are using it to create a Javascript Date object, be sure to append the correct time zone and to request it back also in the correct time zone.

Or get rid of the Javascript Date object altogether and treat it as string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.