Javascript date computing example analysis _ javascript skills

Source: Internet
Author: User
This article mainly introduces javascript date computation, which involves related techniques related to javascript date computation. you need to pay attention to the use of indexes. if you need it, you can refer to the following example to describe javascript date computation. Share it with you for your reference. The details are as follows:

Function setLeaveDate () {var inDay = $ ("# date_6 "). val (); // The obtained date format is 2014-07-03 var date = inDay. split ('-'); // separate dates into numbers var num = $ (". time_lk "). val () * 1; // The number of days to be added var year = date [0] * 1; var month = date [1] * 1; var day = date [2] * 1 + num; var d = new Date (month + "/" + day + "/" + year); // Get a date object, note: Here the month and calendar correspond to var weekday = new Array (7); // add an Array of weekday displayed in the resolution week [0] = "Sunday "; weekday [1] = "Monday"; weekday [2] = "Tuesday"; weekday [3] = "weekday "; Weekday [4] = "Thursday"; weekday [5] = "Friday"; weekday [6] = "Saturday"; month = d. getMonth () + 1; // Note: the month here is still changed, and the index of the month is 0 ~ 11, // therefore, adding 1 here will change back to the month corresponding to the calendar. result = month + "month" + d. getDate () + "day
"+ Weekday [d. getDay ()] +" leaving "; $ (". time_2 "). text (result );}

I hope this article will help you design javascript programs.

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.