Reputation: 101
I have a very simple query which i am not getting how to correct this format structure.
I have a string as follows
var date = "11/21/2016'
I need to change it to this format
var date = '20161122'
Any idea how to achieve this
Upvotes: 0
Views: 49
Reputation: 973
If you do not want to use a library:
var parts = date.split("/");
var finalDate = parts[2] + parts[0] + parts[1];
The finalDate
is the answer.
Upvotes: 1