Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get data and time in javascript

var date_time = new Date().toLocaleString();
console.log(date_time);
Comment

get current data and time in javascript

To get time and date you should use

    new Date().toLocaleString(); >> "09/08/2014, 2:35:56 AM"

To get only the date you should use

    new Date().toLocaleDateString(); >> "09/08/2014"

To get only the time you should use

    new Date().toLocaleTimeString(); >> "2:35:56 AM"
Comment

get time from date javascript

const handleTime = (dataD) => {
    let data= new Date(dataD)
    let hrs = data.getHours()
    let mins = data.getMinutes()
    if(hrs<=9)
       hrs = '0' + hrs
    if(mins<10)
      mins = '0' + mins
    const postTime= hrs + ':' + mins
    return postTime
  }
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

PREVIOUS NEXT
Code Example
Javascript :: generate jwt secret key 
Javascript :: vue settimeout in computed 
Javascript :: find sibling in jquery 
Javascript :: connect mongoose to atlas 
Javascript :: how to imporrt Browserrouter in react 
Javascript :: javascript voice reader 
Javascript :: jquery get element id 
Javascript :: setpresence discord.js 
Javascript :: match password regex 
Javascript :: show 5 entries in datatable 
Javascript :: how to get the value of radio button in jquery 
Javascript :: js input trigger change event when set value with js 
Javascript :: how can i validate an email address in javascript 
Javascript :: js letters alphabet array 
Javascript :: graphqlHTTP is not a function 
Javascript :: jquery datatable returning current datetime 
Javascript :: hide show div using jquery 
Javascript :: first program in node js 
Javascript :: title case javascript 
Javascript :: vue.js use scss in balise style 
Javascript :: adding event on keypress in javascript 
Javascript :: how to check if file upload is empty jquery 
Javascript :: how to convert number to array in javascript using Array.from 
Javascript :: reactdom is not defined 
Javascript :: jquery ajax 
Javascript :: expo build apk 
Javascript :: nodejs sharp get image size 
Javascript :: onchange select dropdown jquery 
Javascript :: sorting array from highest to lowest javascript 
Javascript :: verify radio checked jquery 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =