Answers for "javascript show time"

45

javascript 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")
time.toLocaleString(); //returns date and time (e.g. "9/12/2015, 6:08:25 PM")
time.toLocaleTimeString(); //returns time (e.g. "6:08:25 PM")
time.toLocaleDateString(); //returns date (e.g. "9/12/2015")
Posted by: Guest on May-15-2020
11

today's time in javascript

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;
Posted by: Guest on August-31-2020
8

how to use current data in javascript

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
Posted by: Guest on April-21-2020
7

javascript date get current date

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
//var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;
The dateTime variable contains result as:

2018-8-3 //11:12:40
Posted by: Guest on May-19-2020
3

get today date and time in js

date.toString('YYYY-MM-dd'); 'Tue Feb 10 2015 15:42:50'

var date = new Date('4-1-2015');

date.getDay();// returns 3    

date.getYear();// returns 115, no of years after 1900

date.getFullYear();// returns 2015 

date.getMonth();// returns 3, starting 0 with jan 

date.getUTCDate();// returns 31
Posted by: Guest on May-22-2020
4

javascript get Time

var d=new Date();
d.getTime();//I'm in milliseconds, divide by 1000 for seconds
Posted by: Guest on June-28-2019

Code answers related to "Javascript"

Browse Popular Code Answers by Language