Tzook Bar Noy
Tzook Bar Noy

Reputation: 11677

weird sql, and javascript ajax error

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.

Upvotes: 0

Views: 76

Answers (1)

AndreKR
AndreKR

Reputation: 33697

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.

Upvotes: 1

Related Questions