How to use setUTCDate in JavaScript
In this article, I will explain use of setUTCDate() method in JavaScript date object.
JavaScript setUTCDate() method
-
setUTCDate() method of date object sets the numeric day of the month for a specified date according to the UTC time.
-
UTC is The Universal Coordinated Time. it is the set by the World Time Standard.
-
UTC time is the same as GMT time.
Syntax
Date.setUTCDate(dayValue)
|
Example
In the following example show to setUTCDate() method sets the day of the month, according to UTC.
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Aqua ">JavaScript setUTCDate() Method Example</h3>
<p id="demo">Click to display the date after set the day of the month.</p>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction() {
var d = new Date();
d.setUTCDate(18);
var x = document.getElementById("demo");
x.innerHTML ="Changing Date according to UTC : "+ d;
}
</script>
</body>
</html>
|
Output1
Output2
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
Programming Answers here