new Date summing 1 month

18 views
Skip to first unread message

Ricardo Pereira

unread,
Sep 2, 2015, 8:03:52 PM9/2/15
to Google Visualization API

I am using the charts for some months but I've never realized that, just today I saw it.


The problem is, for example when we use [new Date(2015,01,10),1000] , it shows February, when it was supposed to show January.


Here is a fiddle example: https://jsfiddle.net/ns91ft9v/1/


And even the examples on the chart docs (https://google-developers.appspot.com/chart/interactive/docs/datesandtimes) are summing 1 month.


I couldn't find nowhere else someone reporting this issue, and I've tried on many different browsers.


Am I getting crazy or there is a real issue here?

Daniel LaLiberte

unread,
Sep 2, 2015, 10:13:44 PM9/2/15
to Google Visualization API
When you use the Date constructor, the month numbers start at 0, not 1.  This is a frequently tripped-over issue with JavaScript Dates (as well as for most languages). 

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/eae714e8-4e57-4fad-a096-5adec57826c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Ricardo Pereira

unread,
Sep 3, 2015, 11:57:40 AM9/3/15
to Google Visualization API
Oh thank you... I was getting confused by the fact that 12 was showing January... 

tks!


Em quarta-feira, 2 de setembro de 2015 23:13:44 UTC-3, Daniel LaLiberte escreveu:
When you use the Date constructor, the month numbers start at 0, not 1.  This is a frequently tripped-over issue with JavaScript Dates (as well as for most languages). 
On Wed, Sep 2, 2015 at 8:03 PM, Ricardo Pereira <ricardobar...@gmail.com> wrote:

I am using the charts for some months but I've never realized that, just today I saw it.


The problem is, for example when we use [new Date(2015,01,10),1000] , it shows February, when it was supposed to show January.


Here is a fiddle example: https://jsfiddle.net/ns91ft9v/1/


And even the examples on the chart docs (https://google-developers.appspot.com/chart/interactive/docs/datesandtimes) are summing 1 month.


I couldn't find nowhere else someone reporting this issue, and I've tried on many different browsers.


Am I getting crazy or there is a real issue here?

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
0 new messages