Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current date in this format [duplicate]

How can I get the current date in Javascript and format it this way "2015-03-25T12:00:00" ?

I would like to know if there is a function or method for this. I am not asking how to convert a string into another.

like image 527
user1869935 Avatar asked Feb 17 '16 19:02

user1869935


1 Answers

To be precise: .toISOString().slice(0, -5)

var d1 = new Date()
var str = d1.toISOString().slice(0, -5)
console.log(str);
like image 95
user2167582 Avatar answered Oct 16 '22 00:10

user2167582