0

hey,

I need a 24 hr i.e 00:00 to 23:59 timepicker in javascript.
Precisely, the requirement is such that the database format are 24 hr timestamps. Hence I cant use am or pm time pickers..

Plz help guyzz..

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Airshow
0

I'm not sure what you mean by "timepicker" but maybe you want something like this:

function getDate24(d) {
	try { return d.getHours() + ':' + d.getMinutes(); }
	catch(e) { return false; }
}

which returns a hh:mm string when fed with a javascript Date. If something other than a Date is passed in, then false will be returned, which you can test for and take appropriate alternative action. This approach will prevent generating a javascript error and consequential crash.

Sample call, for current local computer time, would be:

var timeStr24 = getDate24(new Date());

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.