JavaScript .setUTCDate()
Published Aug 11, 2023
Contribute to Docs
The .setUTCDate() method changes the day of a Date object in Coordinated Universal Time (UTC).
Syntax
myDate.setUTCDate(day)
The .setUTCDate() method receives a day argument representing a number between 1 to 31.
Example
In this example, .setUTCDate() is used to modify the day of myDate to 10.
var myDate = new Date('Jun 26, 2023 18:10:40');myDate.setUTCDate(10);console.log(myDate.toString());
Output:
Tue Jun 10 2023 18:10:40 GMT+0000 (Coordinated Universal Time)
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.15 hours