how to covert javascript Date() to COleDateTime
Javascript ca开发者_StackOverflow社区ll COM interface. I want to convert to Date() to COleDateTime(ATLCOM) or DATE. or other method?
// com interface
STDMETHODIMP ITest::Convert(DATE t2, BSTR t1)
// javascript
function btn_onclick() {
var t1 = new Date();
var t2 = new Date("October 13, 2000 11:13:00").toString();
ITest.Convert(t1, t2); // not worked!
}
A jscript Date is an automation object (VARIANT with VT = VT_DISPATCH for ATL). The easiest way to get its value passed would be calling its toUTCString method and pass the string in UTC time instead. If you want to pass the object directly to save some scripting, call the getUTCFullYear/getUTCMonth/getUTCDay/getUTCHours/getUTCMinutes/getUTCSeconds/getUTCMilliseconds/getTimezoneOffset methods via its IDispatch interface to get the exact time.
You can view the object's type library in jscript.dll using OleView.
精彩评论