把对象JSON序列化,然后反序列化后发现时间少了八小时.因为在东八区,所以序列的时候按照1970-01-01:08:00:00为基数取得差值,而反序列化的时候以1970-01-01:00:00:00作为的基数反序列成了标准时间,所以需要ToLocalTime一下或者手动+8. class Program { static void Main(string[] args) { UserInfo userInfo = new UserInfo(); userInfo.CreateTime = Dat
//获取当前时间戳 var timestamp = Date.parse(new Date()); timestamp = timestamp / 1000; console.log("当前时间戳为:" + timestamp); //获取当前时间 var n = timestamp * 1000; var date = new Date(n); //年 var Y = date.getFullYear(); //月 var M = (date.getMonth() + 1 <