开发者

How to get today's date in Javascript?

开发者 https://www.devze.com 2023-03-26 18:11 出处:网络
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:

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 2开发者_JAVA百科011 @ 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();

will give you the current date.


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

console.log(currentDate());
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号