1 将系统时间转换成unix时间戳
datetime dtstart = timezone.currenttimezone.tolocaltime(new datetime(1970,1,1));
datetime dtnow = datetime.parse(datetime.now.tostring());
timespan tonow = dtnow.subtract(dtstart);
string timestamp = tonow.ticks.tostring();
timestamp = timestamp.substring(0,timestamp.length - 7);2将unix时间戳转换成系统时间
string timestamp = "1144821796";
datetime dtstart = timezone.currenttimezone.tolocaltime(new datetime(1970,1,1));
long ltime = long.parse(timestamp + "0000000");
timespan tonow = new timespan(ltime);
datetime dtresult = dtstart.add(tonow);
短短几行代码,却花了我几个小时,就因为时区的问题,@[email protected]
新闻热点
疑难解答
图片精选