JavaScript .setMinutes()
Anonymous contributor
Published Jun 15, 2023
Contribute to Docs
The .setMinutes() method changes the minute value of a date according to local time.
Syntax
myDate.setMinutes(minutesValue);
The .setMinutes() method is called on Date object myDate with an input argument minutesValue that contains the desired minute value.
Example
The example below shows a basic implementation of the function in which the minutes of eventDay are changed from 20 to 30.
const eventDay = new Date('June 11, 2023 14:20:29');eventDay.setMinutes(30);const hoursMinutes = eventDay.getHours() + ':' + eventDay.getMinutes();console.log(hoursMinutes);
The example above results in the following output:
14:30
Codebyte Example
The code example below sets the minute value of eventDay to 30. The current minute value is then logged to the console.
All contributors
- Anonymous contributor
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