Days from a specified holiday

Source: Internet
Author: User

After saving the following code as a JS file, you can reference it on the page where it needs to be displayed. The Code is as follows:

  1. // JScript File
  2. Calendar = new date ();
  3. Day = calendar. getday ();
  4. Month = calendar. getmonth ();
  5. Date = calendar. getdate ();
  6. Year = calendar. getyear ();
  7. If (year <100) year = 1900 + year;
  8. Cent = parseint (Year/100 );
  9. G = year % 19;
  10. K = parseint (cent-17)/25 );
  11. I = (cent-parseint (cent/4)-parseint (cent-k)/3) + 19 * g + 15) % 30;
  12. I = I-parseint (I/28) * (1-parseint (I/28) * parseint (29/(I + 1) * parseint (21-g) /11 ));
  13. J = (Year + parseint (Year/4) + I + 2-cent + parseint (cent/4) % 7;
  14. L = I-j;
  15. Emonth = 3 + parseint (L + 40)/44 );
  16. Edate = L + 28-31 * parseint (emonth/4 ));
  17. Emonth --;
  18. VaR dayname = new array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
  19. VaR monthname =
  20. New array ", "October", "November", "December ");
  21. Document. Write ("<font color = ff0000>" + year + "year ");
  22. Document. Write (monthname [month]);
  23. Document. Write (date + "day ");
  24. Document. Write (dayname [Day] + "" + "</font> ");
  25. // January (the February Festival, which is the same as the following .)
  26. Month ++;
  27. VaR datearray = new array ();
  28. Datearray [0] = new array ("2008/1/1", "2008/2/7", "2008/2/21", "2008/4/4", "2008/5/1", "2008/7/1", "2008/8/1 ", "2008/9/14", "2008/10/1", "2008/12/25 ",
  29. "Medium", "2009/1/26", "2009/2/9", "2009/3/8", "2009/4/4", "medium", "medium", "2009/8/1", "2009/9/3", "2008/10/1 ", "2009/12/25 ",
  30. "Expiration", "2010/2/14", "2010/2/28", "2010/3/8", "2010/4/4", "Expiration", "2010/8/1", "2010/9/22", "2010/10/1 ", "2010/12/25 ",
  31. "Region", "region", "2011/2/17", "2011/3/8", "2011/4/4", "region", "2011/7/1 1/8/1", "2011/9/12", "2011/10/1 ", "2011/12/25 ",
  32. "Expiration", "2012/1/23", "Expiration", "2012/3/8", "2012/4/4", "Expiration", "Expiration", "2012/8/1", "2012/9/30", "2012/10/1 ", "2012/12/25 ");
  33. Datearray [1] = new array ("New Year's Day", "Spring Festival", "Lantern Festival", "Women's Day", "Tomb Sweeping Day", "Labor Day", "Party Building Festival ", "Jianjun Festival", "Mid-Autumn Festival", "National Day", "Christmas ",
  34. "New Year's Day", "Spring Festival", "Lantern Festival", "Women's Day", "Tomb Sweeping Day", "Labor Day", "Party Building Festival", "army building Festival", "Mid-Autumn Festival ", "National Day", "Christmas ",
  35. "New Year's Day", "Spring Festival", "Lantern Festival", "Women's Day", "Tomb Sweeping Day", "Labor Day", "Party Building Festival", "army building Festival", "Mid-Autumn Festival ", "National Day", "Christmas ",
  36. "New Year's Day", "Spring Festival", "Lantern Festival", "Women's Day", "Tomb Sweeping Day", "Labor Day", "Party Building Festival", "army building Festival", "Mid-Autumn Festival ", "National Day", "Christmas ",
  37. "New Year's Day", "Spring Festival", "Lantern Festival", "Women's Day", "Tomb Sweeping Day", "Labor Day", "Party Building Festival", "army building Festival", "Mid-Autumn Festival ", "National Day", "Christmas ");
  38. VaR jier = ""
  39. VaR tians = ""
  40. For (I = 0; I <datearray [0]. length; I ++)
  41. {
  42. VaR urodz = new date (datearray [0] [I]);
  43. VaR S = datearray [1] [I];
  44. VaR now = new date ();
  45. VaR Ile = urodz. gettime ()-Now. gettime ();
  46. VaR DNI = math. Floor (Ile/(1000*60*60*24 ));
  47. If (DNI> 0)
  48. {
  49. Jier = s
  50. Tians = DNI
  51. Break;
  52. }
  53. }
  54. Document. Write ("distance" + jier + "and" + tians + "day ")
  55. Document. Write ("<br> </font> ");

The reference method code is as follows:

  1. <Script language = "JavaScript" src = JScript. js> </SCRIPT>

The above script can also be bound to the database, which is not described here.

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.