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
Minimum security baseline document for windows 2008 r2
How can I shrink a LDF file of 54GB?
CMDKEY error message
Setting Up Raid On Windows 2003 Server With Faulty Hard Drive
A non-SYN packet was dropped because it was sent by a source that does not have an established connection with the Forefront TMG computer
vb script to ping hosts and check operating system
How to separate multiple email accounts into different data files in Outlook 2010
Complete memory dump not available for servers with >=2GB RAM : other options WinDbg : blue screen crash
KMS Activation Multiple Keys
Move Mailbox Powershell Script (sending Welcome e-mail HTML format)