简体   繁体   中英

setHours to 5pm

Ok, this might sound stupid and noob but right now in my js, I have this code:

var date = new Date();
    date.setHours(5, 00, 00);

which will give me 5:00:00. Is there a way to set it to am/pm?

setHours uses 24-hour time. So, 5PM in 24-hour time is 17, ie

date.setHours(17,0,0);

From here .

setHours uses a 24-hour time format

http://www.w3schools.com/jsref/jsref_setHours.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM