JS in about date

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.