How to get current date in JavaScript?
P粉463291248
P粉463291248 2023-08-23 13:54:25
0
2
456
<p>How to get the current date in JavaScript? </p>
P粉463291248
P粉463291248

reply all(2)
P粉742550377

var utc = new Date().toJSON().slice(0,10).replace(/-/g,'/');
document.write(utc);

If you want to reuse a utc variable (e.g. new Date(utc)), use the replace option, as Firefox and Safari do not recognize dashes date.

P粉618358260

Use new Date()Generate a new Date object containing the current date and time.

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();

today = mm + '/' + dd + '/' + yyyy;
document.write(today);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!