JackBrown JackBrown - 1 month ago 15
Vb.net Question

JavaScript dates conversion from an Outlook email

I am trying to capture all possible scenario of dates from an Outlook email and convert them into a javascript date object using the "new Date()" function. However, when I try to parse them into the date object, it returns an invalid date.

For Example: 10/25/2016 09:44:38 AM - this works fine and returns the correct date and time
25/10/2016 09:44:38 - This returns an invalid date

Code:

// This code is on the page of a web browser control that receives the Outlook date
function thisFunctionIsInvokedFromOutlook(dateStringValue) {
var dateValue = new Date(dateStringValue);
}


Any reasons why and how I can resolve this issue?

Answer

I managed to achieve this myself. Basically, VB.Net has a date format option that will convert the any Outlook email date format to a specified one. So, all I do is make sure I do the conversion in VB.Net and always convert it to a specific format for javascript to see it and get its date object based on that format.

Format(dateFromOutlookEmail,"MM/dd/yyyy hh:mm:ss")