Microsoft
Software
Hardware
Network
Question : Time/Date Function Timestamp Incorrect
I have the following function that works well except between the hours of 12:00 pm and 1:00 pm. During this time, the time will display as am ... What is wrong with this function?
function formatTime(date) {
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
var ampm = (hh>12)?"pm":"am";
if (hh>12) hh-=12;
if (mm<10) mm="0"+mm;
return hh+':'+mm+':'+ss+' '+am;
}
The timestamp appears in the Subject line of my email:
formObj.Subject.value='ITM
S Service Request '+formatTime(new Date());
return true; // submits the form
}
Answer : Time/Date Function Timestamp Incorrect
this line
var ampm = (hh>12)?"pm":"am";
should be
var ampm = (hh>=12)?"pm":"am";
Random Solutions
Changing fileserver password
Windows XP - BSOD STOP: C000021a The windows logon process terminated unexpectedly with a status of 0x00000005 (0x00000000 0x00000000)
MS CRM Duplicate Detection rule not working
Routing and remote access VPN ip.
Rpc over Https
Thread v/s Runnable
Large Calendar
IBM System x3400 8K-I RAID Controller query
Infopath Form service comparison between SharePoint 2007 and SharePoint 2010
Script to Remove Groups from the "Member of" groups in a list of user accounts