Fri Oct to 18:00:00 utc+0800 2008 conversion 2008-10-31
function Todate (num) {//Fri Oct to 18:00:00 utc+0800num = num + ""; var date= ""; Var month=NewArray (); month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["APR"] = 4; Month["may"] = 5; month["Jan"] = 6; month["Jul"] = 7; Month[""] = 8; month["SEP"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12; Var week=NewArray (); week["Mon"] = "one"; week["Tue"] = "two"; week["Wed"] = "three"; week["Thu"] = "four"; week["Fri"] = "five"; week["Sat"] = "six"; Week["Sun"] = "Day"; STR= Num.split (""); Date= Str[5] + "-"; Date= Date + month[str[1]] + "-" + str[2]; returndate;}
Process timestamps into a standard format
function Time_deal (time_stamp) { = time_stamp.substring (0,4); = time_stamp.substring (4,6); = time_stamp.substring (6,8); = year+ "-" +month+ "-" + day; return New_time;}
Calculate how many days the difference is between two dates
/*** Calculate the number of days difference between two dates *@paramStrdatestart *@paramStrdateend * @returns*/function GetDays (strdatestart,strdateend) {var strseparator= "-";//Date Separatorvar oDate1; var ODate2; var idays; ODate1=Strdatestart.split (Strseparator); ODate2=Strdateend.split (Strseparator); var strdates=NewDate (Odate1[0], odate1[1]-1, odate1[2]); var strdatee=NewDate (Odate2[0], odate2[1]-1, odate2[2]); Idays= parseint (Math.Abs (strdates-strdatee)/1000/60/60/24)//converts the difference in milliseconds to days returnidays;}
Get current time
/*** Get current time*/function Getnowformatdate () {var date=NewDate (); var Seperator1= "-"; var Seperator2= ":"; Var month= Date.getmonth () + 1; var strdate=date.getdate (); if(Month >= 1 && month <= 9) {Month= "0" +month; } if(strdate >= 0 && strdate <= 9) {strdate= "0" +strdate; } var currentdate= Date.getfullyear () + seperator1 + month + Seperator1 +strdate;//+ "" + date.gethours () + Seperator2 + date.getminutes ()//+ Seperator2 + date.getseconds (); returncurrentdate;}
JS in about date