“Mengembalikan tanggal saat ini di JavaScript” Kode Jawaban

Mengembalikan tanggal saat ini di JavaScript

let today = new Date().toLocaleDateString()

console.log(today)
Poor Polecat

Tanggal JavaScript Dapatkan Tanggal Saat Ini

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
Exuberant Elk

Dapatkan JavaScript Tanggal Hari Ini

var today = new Date();

var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
Hastings Keith

bagaimana mendapatkan tanggal saat ini di JS

let today = new Date();
let month = today.getMonth() + 1;
month = month < 10 ? "0" + month : month;
let days = today.getDate() < 10 ? "0" + today.getDate() : today.getDate();

today = today.getFullYear() + "-" + month + "-" + days;

console.log(today);
Indonesia People

Dapatkan JavaScript Tanggal Hari Ini

var today = new Date();
Joyous Jaguar

Dapatkan Tanggal Hari Ini di JS

var objToday = new Date(),
	weekday = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
	dayOfWeek = weekday[objToday.getDay()],
	domEnder = function() { var a = objToday; if (/1/.test(parseInt((a + "").charAt(0)))) return "th"; a = parseInt((a + "").charAt(1)); return 1 == a ? "st" : 2 == a ? "nd" : 3 == a ? "rd" : "th" }(),
	dayOfMonth = today + ( objToday.getDate() < 10) ? '0' + objToday.getDate() + domEnder : objToday.getDate() + domEnder,
	months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
	curMonth = months[objToday.getMonth()],
	curYear = objToday.getFullYear(),
	curHour = objToday.getHours() > 12 ? objToday.getHours() - 12 : (objToday.getHours() < 10 ? "0" + objToday.getHours() : objToday.getHours()),
	curMinute = objToday.getMinutes() < 10 ? "0" + objToday.getMinutes() : objToday.getMinutes(),
	curSeconds = objToday.getSeconds() < 10 ? "0" + objToday.getSeconds() : objToday.getSeconds(),
	curMeridiem = objToday.getHours() > 12 ? "PM" : "AM";
var today = curHour + ":" + curMinute + "." + curSeconds + curMeridiem + " " + dayOfWeek + " " + dayOfMonth + " of " + curMonth + ", " + curYear;

document.getElementsByTagName('h1')[0].textContent = today;
Big Jojo

Jawaban yang mirip dengan “Mengembalikan tanggal saat ini di JavaScript”

Pertanyaan yang mirip dengan “Mengembalikan tanggal saat ini di JavaScript”

Lebih banyak jawaban terkait untuk “Mengembalikan tanggal saat ini di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya