Flot and Timezone

976 views
Skip to first unread message

Marco Schwarz

unread,
Jun 28, 2011, 6:56:56 AM6/28/11
to Flot graphs
Hi,

I have many (more then 2 ;-)) postgresql databases into different
timezone. I save the date/value info .... I watch the information from
my timezone, the customer watch the same data from his timezone and so
the x-axis is already wrong.

so I save the date without timezone in the database, replace into
jquery.flot.js all function getUTC... with get... (without UTC) and
substract the timezone offset... now the x-axis is correct.

Why Flot convert all to UTC? Do you can use only the data (serie)
timestamp to create the x-axis?

Thanks
Marco

PS: Sorry my English is bad...

Juan Mendes

unread,
Jun 28, 2011, 2:15:25 PM6/28/11
to flot-...@googlegroups.com
From the flot api doc
http://flot.googlecode.com/svn/trunk/API.txt


Normally you want the timestamps to be displayed according to a
certain time zone, usually the time zone in which the data has been
produced. However, Flot always displays timestamps according to UTC.
It has to as the only alternative with core Javascript is to interpret
the timestamps according to the time zone that the visitor is in,
which means that the ticks will shift unpredictably with the time zone
and daylight savings of each visitor.

So given that there's no good support for custom time zones in
Javascript, you'll have to take care of this server-side.

The easiest way to think about it is to pretend that the data
production time zone is UTC, even if it isn't. So if you have a
datapoint at 2002-02-20 08:00, you can generate a timestamp for eight
o'clock UTC even if it really happened eight o'clock UTC+0200.
--
Juan Mendes
Reply all
Reply to author
Forward
0 new messages