本文介绍了返回自1970/01/01以来的毫秒数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在javascrip中
in javascrip
var d = new Date();
var n = d.getTime();
how in c#?
推荐答案
DateTime baseDate = new DateTime(1970, 1, 1);
TimeSpan diff = DateTime.Now - baseDate;
Console.WriteLine(diff.TotalMilliseconds);
Milliseconds属性仅给出TimeSpan的毫秒分量(总计年,天,小时,分钟和秒的数量后剩余的数量),而TotalMilliseconds给出的总毫秒数由值.
The Milliseconds property just gives the milliseconds component of the TimeSpan (the amount left-over after totaling the number of years, days, hours, minutes and seconds), while TotalMilliseconds gives the total number of milliseconds represented by the value.
DateTime baseDate = new DateTime(1970, 1, 1);
TimeSpan diff = DateTime.Now - baseDate;
Console.WriteLine(diff.Milliseconds);
这篇关于返回自1970/01/01以来的毫秒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!