How to convert JavaScript date object to ticks

后端 未结 6 1779
[愿得一人]
[愿得一人] 2020-11-28 04:54

How should I convert JavaScript date object to ticks? I want to use the ticks to get the exact date for my C# application after synchronization of data.

6条回答
  •  無奈伤痛
    2020-11-28 05:17

    If you want to convert your DateTime object into universal ticks then use the following code snippet:

    var ticks = ((yourDateObject.getTime() * 10000) + 621355968000000000);
    

    There are 10000 ticks in a millisecond. And 621.355.968.000.000.000 ticks between 1st Jan 0001 and 1st Jan 1970.

提交回复
热议问题