Reputation: 7651
When i enter the date and submit, the format of my date is \/06\/12\/1967
and i need in the below format to send my JSON.
The Format Needed With the Slashes to be sent.
/Date(1306348200000)/
Upvotes: 1
Views: 219
Reputation: 490537
Your date is pre 1970, so you should be able to take advantage of the negative number to represent dates before that.
var str = '\/06\/12\/1967',
date = new Date(str);
str = '/Date(' + +date + ')/';
If you need it in seconds as opposed to milliseconds, divide by 1000
.
If your date is in the European format (the current date is ambiguous, it could be in either)...
var str = '\/06\/12\/1967',
tokens = str.split('/');
str = [tokens[2], tokens[1], tokens[3]].join('/')
var date = new Date(str);
str = '/Date(' + +date + ')/';
Upvotes: 2