calculate date duration in js

Hi All,

I need to calculate the duration between two SM datetime fields using javascript and return back the result in SM datetime format. Is this possible?

I know it's perfectly possible using simple RAD coding, but I need this to be in js since it can be called using jscall from any other place.