Reputation: 3745
I have a value from my database. How do I extract the date from this datetime value using javascript?
1990-06-03 00:00:00
Upvotes: 2
Views: 4962
Reputation: 142921
Just split up the parts and use the built-in Date
constructor
var t = "1990-06-03 00:00:00".split(/[- :]/);
var date = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
Upvotes: 3