Date.UTC configure javascript time zone

1

I am entering data to a graph, what happens when I bring the data and enter it in the Date.UTC function it adds me one more month giving me an erroneous date example:

Date.UTC(parseInt(val.year),parseInt(val.month),parseInt(val.day), parseInt(val.hour), parseInt(val.min));

Date.UTC(parseInt(2018),parseInt(10),parseInt(08), parseInt(10), parseInt(17));

It returns November 08, 2018 being October 8

he intentado hacer esto sin resultados: 

 new Date().toLocaleString('es-CL', { timeZone: 'America/Santiago' })

Thank you for your attention, I will be attentive to your replies.

    
asked by Javier Antonio Aguayo Aguilar 08.10.2018 в 15:57
source

1 answer

3

The months in Data.UTC start at 0, not at 1, so they go from 0 (January) to 11 (December). Surely your problem is that you feed the function thinking in months from 1 to 12.

You can see it in the doc of the function Date.UTC () :

  

month

     

An integer between 0 and 11 that represents the month.

    
answered by 08.10.2018 / 16:04
source