tags:

views:

37

answers:

2
+1  Q: 

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?

A: 

setHours uses a 24-hour time format

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

Eton B.
+2  A: 

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

date.setHours(17,0,0);

From here.

Michael Todd
@ Michael Todd -- thanks, that did it. I didnt know that setHours uses 24-hour time.
hersh