I have this code but I am getting a format date of Mon Mar 13 2017 19:02:50 GMT-0400 (Eastern Daylight Time), I am trying to get a date and time to this format mm/dd/yyyy 00:00:00 am/pm
I have this challenge to get the current date and time once I click the save button (date and time format should be mm/dd/yyyy 00:00:00 am/pm) and will be saved to the location specified and will clear out the information or details in the input box.(is this possible)
<html>
<head >
<title>Start and stop</TITLE>
<script type="text/javascript">
function pad(part)
{
return ('0' + part).slice(-2);
}
function getDateString() {
var myDate = new Date();
return pad(myDate.getMonth() + 1) +
"/" + pad(myDate.getDate()) +
"/" + myDate.getFullYear() +
' ' + pad(myDate.getHours()) +
":" + pad(myDate.getMinutes()) +
":" + pad(myDate.getSeconds());
}
window.onload = function() {
document.getElementById('date').value = Date();
}
</script>
<script language="javascript">
function WriteToFile(passForm) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileLoc = "C:\\Documents\\tracker.csv";
var file = fso.OpenTextFile(fileLoc,8, true,0);
file.writeline( passForm.StartTime.value + ',' +
passForm.StopTime.value);
file.Close();
}
</script>
</head>
<body BGCOLOR=#FFFF99 SCROLL=NO>
<form>
<CENTER>
<table border=2>
<tr>
<td align=center>
Start time
</td>
<td align=center>
<input type="button" class=button value=" SAVE " onclick="WriteToFile(this.form)">
</td>
</tr>
<TR>
<TD align=center>
<input type="text" name="StartTime" size="25" id="date" class=select disabled="disabled">
</TD>
<TD align=center>
<input type="text" name="StopTime" size="17" class=select disabled="disabled"><!--the stop time will be automatically saved once the save button is clicked-->
</TD>
</TR>
</table>
</form>
</body>
</html>