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 :: sanitize data within an Express application 
Javascript :: data fetch with axios 
Javascript :: string methods javascript 
Javascript :: es6 javascript 
Javascript :: react native elements 
Javascript :: what is linter javascript 
Javascript :: Uncaught ReferenceError: am4core is not defined 
Javascript :: string contains at least one number 
Javascript :: javascript Spread Operator with Object 
Javascript :: how to attach function to button sweetalert2 
Javascript :: You provided a `value` prop to a form field without an `onChange` handler 
Javascript :: array permutation 
Javascript :: convert nested json to csv python 
Javascript :: js check if image url exists 
Javascript :: js string to blob 
Javascript :: how to mock a library in jest 
Javascript :: repeat string in javascript 
Javascript :: navbar route with params vue 
Javascript :: How to add a class to html element js 
Javascript :: Saving values for metaboxes in wordpress 
Javascript :: angular 12 tabs 
Javascript :: react native map 
Javascript :: import an image react in the public folder 
Javascript :: points in three js 
Javascript :: Adding User And Hashed Password In ExpressJS 
Javascript :: includes in js 
Javascript :: getboundingclientrect 
Javascript :: react tailwind loading 
Javascript :: react datepicker 
Javascript :: jquery autocomplete bootstrap modal 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =