Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get data and time in javascript

var date_time = new Date().toLocaleString();
console.log(date_time);
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

js get time

// these are the most useful ones IMO
var time = new Date();
time.getDate(); // returns value 1-31 for day of the month
time.getDay(); //returns value 0-6 for day of the week
time.getFullYear(); //returns a 4 digit value for the current year
time.getHours(); //returns value 0-23 for the current hour
time.getMinutes(); //returns value 0-59 for the current minute of the hour
time.getSeconds(); //returns value 0-59 for current second of the minute
time.getMilliseconds(); //returns value 0-999 for current ms of the second
time.getTime(); //returns date as ms since Jan 1, 1970
time.toDateString(); //returns a string (e.g. "Fri May 9 2020")
Comment

PREVIOUS NEXT
Code Example
Javascript :: js setinterval 
Javascript :: moment js difference between two dates 
Javascript :: add css on click javascript 
Javascript :: javascript read server file 
Javascript :: vue inline style bind 
Javascript :: shadow using react native 
Javascript :: Write the JavaScript code to set the width of element to 50%; 
Javascript :: mean vs mern stack 
Javascript :: Bots latency discord js 
Javascript :: how to define state in react function 
Javascript :: node.js dns lookup 
Javascript :: add class javascript 
Javascript :: js insertbefore 
Javascript :: get last item in array javascript 
Javascript :: disable button in swal popup 
Javascript :: react native android padding style 
Javascript :: javascript remove duplicates from array 
Javascript :: What is data modeling in MongoDB 
Javascript :: ngx toastr 
Javascript :: clear interval e.close is not a function 
Javascript :: jquery google 
Javascript :: what is type coercion in javascript 
Javascript :: $ is not a function 
Javascript :: regexp constructor js 
Javascript :: how to change size of image js 
Javascript :: javascript clear input string 
Javascript :: jquery on click outsile hide div 
Javascript :: convert result of .innerHTML to number on javascript 
Javascript :: convert days into year, Month, days 
Javascript :: js get element by attribute 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =