-1

I have a date string like "2010,1,4" which stands for 4th Jan 2010 and I want to use this string as UTC datetime to draw chart using highcharts. How can I convert this string to UTC date time format, something like: Date.UTC(2010,0,4).

Thanks a lot !

jlbriggs
  • 17,612
  • 4
  • 35
  • 56
Ock
  • 418
  • 8
  • 24

3 Answers3

3

Is this what you're looking for?

var test = Date.UTC(2010,0,4); var utcDate = new Date(test); utcDate;
Dane
  • 312
  • 2
  • 10
0

Stringdate is converted to UTC date time format, in variable n you have the result ....

var stringdate="2010,1,4";
var d = new Date(stringdate);
var n = d.toUTCString();
Akshay Dubey
  • 79
  • 1
  • 4
0

try this :

new Date(2010,1-1,4).toUTCString()

means new Date(year, month-1, date).toUTCString()

you have to do -1 in month because it start month index from 0 (for eg: january = 0)

rahul
  • 7,573
  • 7
  • 39
  • 53
leena
  • 302
  • 3
  • 7