I have a date string like this: "2010-07-12T00:00:00"
,
I would like to convert this date string to UTC format.
how do I convert this string date("2010-07-12T00:00:00"
) to UTC date format?
Asked
Active
Viewed 714 times
0

Brk
- 1,247
- 2
- 23
- 55
-
1It's not clear what you're asking. Are you looking for a specific format, or are you trying to convert between time zones? Will this do: `new Date("2010-07-12T00:00:00").toUTCString()` ? – David Hedlund Jun 07 '16 at 12:33
-
1UTC is a standard, not a format. The string is in an ISO 8601 format. As has no time zone, it will represent a different moment in time depending on the time zone assumed in conversion (whether the assumed time zone is UTC/GMT or any other). – RobG Jun 07 '16 at 12:59
2 Answers
1
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var d = new Date("2010-07-12T00:00:00");
document.getElementById("demo").innerHTML = d;
</script>
</body>
</html>

Abhishek
- 2,485
- 2
- 18
- 25
1
Something like this maybe?
new Date("2010-07-12T00:00:00").toUTCString();

asenovm
- 6,397
- 2
- 41
- 52
-
1No, not like that. The string may be parsed as UTC, local or an invalid date by browsers in use. – RobG Jun 07 '16 at 12:55