什么是DateTime.ToOADate()在JavaScript中的相同呢? [英] What is equivalent of DateTime.ToOADate() in javascript?

查看:1272
本文介绍了什么是DateTime.ToOADate()在JavaScript中的相同呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在JavaScript中OADate(OLE自动化日期)?我需要我的约会对象传递(给我的web服务)的双精度值的形式

How can I get the OADate (OLE Automation date) in javascript? I need to pass my date object (to my web service) in the form of a double value.

在C#中:

var d = DateTime.Now.ToOADate();



什么是JS等价?

what is the equivalent in js?

推荐答案

如果您不能修改的网络服务,你必须重新实现 ToOADate()

If you can't modify the web service, you'll have to re-implement ToOADate().

MSDN说:

这是OLE自动化日期是作为其$一个浮点数b $ b积分分量的天数之前或之后的午夜,30
1899年12月,并且其小数部分代表在
那天提高24分。例如,午夜的时候,1899年12月31日是以1.0表示
;早晨6点,1900 1月1日由2.25代表;
午夜,1899年12月29日由-1.0代表;与6日上午,29
1899年12月由-1.25表示。

An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.

因此​​,你应该能够写类似

Thus, you should be able to write something like

var oaDate = (date - new Date(1899, 11, 31)) / (24 * 60 * 60 * 1000);



(未经测试)

(untested)

这篇关于什么是DateTime.ToOADate()在JavaScript中的相同呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆