C# 的时间戳 在flash actionscript中使用

眼下在做一个项目,要以字节的方式传时间戳到flash中,

错误的就不写了。仅仅写一个能够使用的例如以下:

C#

            DateTime centuryBegin = new DateTime(1970, 1, 1,0,0,0);
            DateTime currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute,DateTime.Now.Second);
            long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks;

输出14071475100000000

flash actionscript

 var d:Date = new Date(0);
			 trace(d);
			 d.setMilliseconds(1407147510000); //14071475100000000传过来的是纳秒10^9,而这里是毫秒
			 trace(d);			 


 

输出
Mon Aug 4 18:18:30 GMT+0800 2014

要注意C#中是纳秒会多出10^4倍

而as中是毫秒1407147510000

发现时间还是不正确,在flash里输出

 trace(d.timezoneOffset);//-480分钟,也就是刚好8个小时,我加上时差的毫秒数

把上面的设置毫秒数的语句改为

d.setMilliseconds(NowDateTime+d.timezoneOffset*60*1000);

再输出d值:

Tue Aug 5 15:19:52 GMT+0800 2014

 

posted @ 2018-02-03 18:46  zhchoutai  阅读(151)  评论(0编辑  收藏  举报