function getCurrentDateTime() {
var current_time = new Date();
var year = current_time.getFullYear();
var month = current_time.getMonth() + 1;
var day = current_time.getDate();
var hour = current_time.getHours();
var minutes = current_time.getMinutes();
var amPM = 'am';
var today = month + '/' + day + '/' + year;
if(hour > 12) {
hour = hour - 12;
amPM = 'pm';
} else if(hour == 0) {
hour = 12;
} else if(hour == 12) {
amPM = 'pm';
}
document.getElementById('input_8_1').value = today;
document.getElementById('input_8_2_1').value = hour;
document.getElementById('input_8_2_2').value = minutes;
document.getElementById('input_8_2_3').value = amPM;
}
Grab current date and time and update input values
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.