简体   繁体   中英

How to get today's date in Javascript?

I would like to a way to get the current date in Javascript.

I would also like the date to be displayed in this format:
dd month year @ hh:mm:ss EDT

for today's date that would work out to:
04 Aug 2011 @ 20:24:38 EDT

Thanks

var d=new Date();
d.toUTCString();

Is this what you need?

You can easily build it yourself with the Date object 's various properties. To get a Date object representing the current moment in time, use

var now = new Date();

Go grab date.js . It can do what you want.

new Date();

会给你当前日期。

let currentDate = (date = new Date()) => `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`

console.log(currentDate());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM