的Javascript Date.getTime的C#版本() [英] C# version of Javascript Date.getTime()

查看:129
本文介绍了的Javascript Date.getTime的C#版本()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是C#获取JavaScript date.gettime的相同结果的最佳方式()调用?




的getTime()方法返回自1970年1月1日,并在指定的日期午夜的毫秒数。



解决方案

您可以使用此解决方案...

 私人的Int64 GETTIME()
{
的Int64 RETVAL = 0;
变种ST =新日期时间(1970,1,1);
时间跨度T =(DateTime.Now.ToUniversalTime() - ST);
RETVAL =(Int64的)(t.TotalMilliseconds + 0.5);
返回RETVAL;
}


What is the best way in c# to get the same result of javascript date.gettime() call?

The getTime() method returns the number of milliseconds since midnight of January 1, 1970 and the specified date.

解决方案

you can use this solution...

  private Int64 GetTime()
  {
      Int64 retval=0;
      var  st=  new DateTime(1970,1,1);
      TimeSpan t= (DateTime.Now.ToUniversalTime()-st);
       retval= (Int64)(t.TotalMilliseconds+0.5);
      return retval;
  }

这篇关于的Javascript Date.getTime的C#版本()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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