Date values are one month ahead

432 views
Skip to first unread message

T.Abilo

unread,
Jul 4, 2011, 12:36:25 PM7/4/11
to Google Visualization API
Since a few days I notice a strange behaviour. Both in my own charts
and in those at the playground the dates of value are one month ahead.

For example at:

http://code.google.com/apis/ajax/playground/?type=visualization

when you choose "Basics - Annotated Time Line",

the values are data.setValue(5, 0, new Date(2008, 1 ,6)); etc. but are
displayed as February instead of January.

I see this behaviour at different PCs and with different browsers.
System time is correct.

Is anybody able to confirm/deny this behaviour or does anybody have
ideas to resolve it?

Riccardo Govoni ☢

unread,
Jul 4, 2011, 7:36:46 PM7/4/11
to google-visua...@googlegroups.com
This is the way javascript works: Month numbering in javascript dates starts from 0, so 0 is January, 1 is February and so on.

This is defined in the ECMAscript standard (section 15.9.1.4 of http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) and also clarified in simpler terms here (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date). That's why you experience it on all browsers... it's just the standard behavior (and unlikely to have changed only in the last few days, it has been like that for a while :-) ).

/R.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


T.Abilo

unread,
Jul 5, 2011, 1:02:20 AM7/5/11
to Google Visualization API
Thanks, maybe I just didn´t notice it previously ;)

On 5 Jul., 01:36, Riccardo Govoni ☢ <battleho...@gmail.com> wrote:
> This is the way javascript works: Month numbering in javascript dates starts
> from 0, so 0 is January, 1 is February and so on.
>
> This is defined in the ECMAscript standard (section 15.9.1.4 ofhttp://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262...)
> and also clarified in simpler terms here (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/...).
Reply all
Reply to author
Forward
0 new messages