1var date = new Date(); //Will use computers date by default.
2//parameters will specify date you put to input
3var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);
1<button onclick="displayDate()">The time is?</button>
2
3<script>
4function displayDate() {
5 document.getElementById("demo").innerHTML = Date();
6}
7</script>
1var d = new Date(),
2 minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
3 hours = d.getHours().toString().length == 1 ? '0'+d.getHours() : d.getHours(),
4 ampm = d.getHours() >= 12 ? 'pm' : 'am',
5 months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
6 days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
7return days[d.getDay()]+' '+months[d.getMonth()]+' '+d.getDate()+' '+d.getFullYear()+' '+hours+':'+minutes+ampm;