this is an example I laid out the other day... might be useful...
heres the output :
You are going to experience problems with this method unless you format your
Date from SQL in an acceptable format ( as presented below ) before it hits
your JS code.
01-24-2006 13:30:00
Tue Jan 24 13:30:00 PST 2006
1:30 PM
The time is now : 8:32 AM
D.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<pre>
You are going to experience problems with this method unless you format your
Date from SQL in an acceptable format ( as presented below ) before it hits
your JS code.
01-24-2006 13:30:00
</pre>
<script>
Date.prototype.humanTime = function () {
var sDate = new String(), sHour = new String(), sAMPM = new String();
sHour = this.getHours() % 12 ;
sAMPM = parseInt(this.getHours()) > 11 ? ' PM' : ' AM';
if (sHour == 0) sHour = 12;
sDate = sHour + ':' + this.getMinutes() + sAMPM;
return (sDate.toString());
}
var someDate= new Date('01-24-2006 13:30:00');
document.write ( '<pre>' + someDate.toString() + '<br />')
document.write ( someDate.humanTime() + '<br />')
var sNow = new Date()
document.write ( 'The time is now : ' + sNow.humanTime() )
document.write ( '</pre>' )
</script>
</body>
</html>
the other john wrote:
The trouble I'm having with PM is that the client chooses their time
via a dropbox. The script it intended for an edit page where the time
already exists in the database. The trouble with PM is when the time
is PM this script is looking for "6" but the time in the database is
"18".