How to use ToString in JavaScript
In this article I am going to explain about toString() method in JavaScript.
JavaScript toString() Method
JavaScript toString() method use for convert date object in to string format. This method not need to call because its method automatically called whenever we want to display Date and Time.
Syntax
Example
<html>
<head>
<script type="text/javascript">
function myfun() {
var dd = new Date();
var mm = document.getElementById("tst");
mm.innerHTML = dd.toString();
}
</script>
</head>
<body>
<p>
click button to show Date</p>
<h4 id="tst" style="color: Blue">
</h4>
<button onclick="myfun()">
click me</button>
</body>
</html>
|
Output

You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here