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
Out of Office Assistant not working w/Forwarding Configured
Sharepoint Template - How to open & Navigate
DAG & CAS array configured but it's not failover
How to find the row count in an Oracle DataReader in ASP.NET?
Audit Report Generation SharePoint Content Viewing
Exchange 2010 "RBAC" error in event log
PHP/Javascript newbie - need help integrating niftycube into my site
Looking for vista drivers for Sony pcg-8112l vista laptop
Which unit test tool contained in Visual Studio 2008?
XP 10 inbound connection limit question