Date toISOString() Method - Javascript Date

Javascript examples for Date:toISOString

Description

The toISOString() method converts a Date object into a string, using the ISO standard whose format is: YYYY-MM-DDTHH:mm:ss.sssZ

Parameters

None

Return Value:

A String, representing the date and time using the ISO standard format

The following code shows how to return a Date object as a String, using the ISO standard:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//w  w w .  j  av a  2 s . co m
    var d = new Date();
    var n = d.toISOString();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials