“JavaScript Дата времени” Ответ

JavaScript Count Time

// The getTime() method returns the number of milliseconds since midnight of January 1, 1970.


var start = new Date().getTime();

for (i = 0; i < 50000; ++i) {
// do something
}

var end = new Date().getTime();
var time = end - start;
alert('Execution time: ' + time);
Helpful Hyena

JavaScript Дата времени

//Date, Time, Timestamp
var today = new Date();
var DD = String(today.getDate()).padStart(2, '0');
var MM = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var YYYY = today.getFullYear();
var hh = today.getHours();
var mm = today.getMinutes();
var ss = today.getSeconds();
today = YYYY + MM + DD + hh + mm + ss;
console.log('Date-Time: ', today);
Jedi

дата времени JS

//Do you need the current time ? ⌚
let date = new Date();
let time = ((date.getHours().toString()).length>1? date.getHours() : "0"+date.getHours()) +":"+ ((date.getMinutes().toString()).length>1? date.getMinutes() : "0"+date.getMinutes());
//If 4h-2min => 04:02
//If 20h-15min => 20:15
Nekå

JavaScript Date Методы

var d= new Date();
d.getFullYear();//Get the year as a four digit number (yyyy)
d.getMonth();//Get the month as a number (0-11)
d.getDate();//Get the day as a number (1-31)
d.getHours();//Get the hour (0-23)
d.getMinutes();//Get the minute (0-59)
d.getSeconds();//Get the second (0-59)
d.getMilliseconds();//Get the millisecond (0-999)
d.getTime();//Get the time (milliseconds since January 1, 1970)
Grepper

JS Get Yeal Month Year

const d = new Date();

d.getMonth() + 1;	// Month	[mm]	(1 - 12)
d.getDate();		// Day		[dd]	(1 - 31)
d.getFullYear();	// Year		[yyyy]
garzj

Дата и время в JavaScript

var dateWithTime = new Date().toLocaleString().replace(",", "")
console.log(dateWithTime)  
//output :6/24/2022 9:36:33 PM
Scary Snake

Ответы похожие на “JavaScript Дата времени”

Вопросы похожие на “JavaScript Дата времени”

Больше похожих ответов на “JavaScript Дата времени” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования