Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

display date in javascript

<button onclick="displayDate()">The time is?</button>

<script>
function displayDate() {
  document.getElementById("demo").innerHTML = Date();
}
</script>
Comment

display time and date in javascript

<!DOCTYPE html>
<html>
<body>

<button type="button"
onclick="document.getElementById('display').innerHTML = Date()">
Click me to display Date and Time.</button>

<p id="display"></p>

</body>
</html>
Comment

how to display date in javascript

var d = new Date(),
    minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
    hours = d.getHours().toString().length == 1 ? '0'+d.getHours() : d.getHours(),
    ampm = d.getHours() >= 12 ? 'pm' : 'am',
    months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
    days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
return days[d.getDay()]+' '+months[d.getMonth()]+' '+d.getDate()+' '+d.getFullYear()+' '+hours+':'+minutes+ampm;
Comment

PREVIOUS NEXT
Code Example
Javascript :: disable button 
Javascript :: node js check if called from command line 
Javascript :: axios cnd 
Javascript :: sum values in array javascript 
Javascript :: sequelize findorcreate 
Javascript :: return a date time object in yyyy-mm-dd hr:min:sec 
Javascript :: Converting file to base64 on Javascript client side 
Javascript :: map list in javascript 
Javascript :: react prevent form submission on enter key press inside inputs 
Javascript :: javascript math methods 
Javascript :: discord.js setactivity 
Javascript :: javascript time script 
Javascript :: p5js import typescript 
Javascript :: javascript duplicate an array 
Javascript :: jquery number counter 
Javascript :: sum all values of an array 
Javascript :: socket.io cors 
Javascript :: make a flat object from object of object list 
Javascript :: use location hook 
Javascript :: js how to sort strings in array 
Javascript :: scroll to element in scrollable div 
Javascript :: remove empty option from bootstrap select javascript 
Javascript :: how to enable javascript 
Javascript :: reverse javascript 
Javascript :: json object check if key exists java 
Javascript :: js canvas draw image 
Javascript :: class component react js 
Javascript :: how to flat an array in javascript iteratively 
Javascript :: js join array 
Javascript :: javascript add event listenner for multiple events 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =