When I parsed this string to date like
var date = new Date("Jan 7, 2014 10:37:42 AM")
This returns the dateTime in local format like
Tue Jan 07 2014 05:07:42 GMT+0530 (India Standard Time)
How can I say that this date is already in UTC?
No, it does not return a dateTime in any format. It does return a Date
object with the internal value of 1389091062000
milliseconds since epoch.
Only when you output it (e.g. when logging it to the console, or casting it to a string with .toString
) it will be represented in your locale's timezone.
If you want to control the output, you would indeed use the toUTCString
method:
var date = new Date("Jan 7, 2014 10:37:42 AM")
date.toUTCString(); // "Tue, 07 Jan 2014 10:37:42 GMT"