简体   繁体   中英

how to covert javascript Date() to COleDateTime

Javascript call 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM