How to get current date in JavaScript?
P粉463291248
P粉463291248 2023-08-23 13:54:25
0
2
421

How to get the current date in JavaScript?

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 autcvariable (e.g.new Date(utc)), use thereplaceoption, as Firefox and Safari do not recognize dashes date.

    P粉618358260

    Usenew Date()Generate a newDateobject 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!