A lot of novice friends of JS in the time format and time stamp conversion is unfamiliar, below for you detailed introduction of the specific conversion steps, interested friends can refer to the following
A. Time conversion timestamp code is as follows: function TransDate (endtime) { var date=new date (); date.setfullyear ( Endtime.substring (0,4)); Date.setmonth (endtime.substring (5,7)-1); Date.setdate (endTime.substring ( 8,10)); date.sethours (endtime.substring (11,13)); date.setminutes (endtime.substring (14,16)); Date.setseconds (endtime.substring (17,19)); return Date.parse (Date)/1000; } two. Timestamp conversion time (1): Convert to 2011-3-16 16:50:43 format: code is as follows: function GetDate (tm) { var tt=new Date (parseint (tm) * 1000). Tolocalestrin g (). Replace (/year | month/g, "-"). Replace (/day/g, "") return tt; } (2): Convert to March 16, 2011 16:50:43: code as follows : function GetDate (tm) { var tt=new Date (parseint (tm) * 1000). toLocaleString () return tt; } (3): Convert to March 16, 2011 16:50 code is as follows: function GetDate (tm) { var tt=new Date (parseint (tm) * 1000). toLocaleString (). s Ubstr (0,16); return tt; }