日期:2014-05-17  浏览次数:20308 次

JS new Date(1301356800000) 是2011-3-29怎么反推出来
怎么从 2011-3-29  这样的格式反推出1301356800000这个东西呢?

------解决方案--------------------
var date=new Date(1301356800000);console.log(date.getFullYear()+'-'+date.getMonth()+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds());
//2011-2-29 8:0:0


var date=new Date(2011,2,29,8, 0, 0);
console.log(date.getTime());//1301356800000

------解决方案--------------------
引用:
怎么从 2011-3-29  这样的格式反推出1301356800000这个东西呢?


 long a =(long) (DateTime.Parse("2011-3-29") - DateTime.Parse("1970-1-1")).TotalMilliseconds;
------解决方案--------------------
Create a Date Object
The Date object is used to work with dates and times. 

Date objects are created with the Date() constructor.

There are four ways of initiating a date:

new Date() // current date and time
new Date(milliseconds) //milliseconds since 1970/01/01
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds)

来自
JavaScript Date Object
http://www.w3schools.com/js/js_obj_date.asp
------解决方案--------------------
                DateTime date = new DateTime(1970, 01, 01);
                DateTime date2 = date.AddMilliseconds(1301356800000);
                Response.Write(date + "<br/>");
                Response.Write((date2 - date).TotalMilliseconds);
                Response.End();