Reputation: 219
Hi I have use the string object for represent the date in the following format
var date="18/01/2011";
var dateFormat="dd/MM/yyyy";
Note:
In my scenorio i have use the dd/MM/yyyy format;
dateFormat will be different in my client side.
how to convert these date default JavaScript dateFormat as MM/dd/yyyy in Generic way.
I have tried in by split date by and swap the month ,date to achieve this requirement. But in my client side i dont know about the format of the date how to convert any other format to default Javascript format
Upvotes: -2
Views: 738
Reputation: 2587
Hope this helps:
var date="18/01/2011";
var parts = date.split('/');
var result = new Date(parts[2], parts[1], parts[0]);
Upvotes: 0