Home >Web Front-end >JS Tutorial >Use js to get the week of the year today is (small example, source code attached)

Use js to get the week of the year today is (small example, source code attached)

亚连
亚连Original
2018-05-18 15:48:092926browse

Below are some interesting examples that I have compiled for you. Interested students can take a look.

 <script language="JavaScript">
<!--
var d1 = new Date();
var d2 = new Date();
d2.setMonth(0);
d2.setDate(1);
var rq = d1-d2;
var s1 = Math.ceil(rq/(24*60*60*1000));
var s2 = Math.ceil(s1/7);
alert("今天是本年第"+s1+"天,第"+s2+"周");//周日做为下周的开始计算
//-->
</script>

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to use ajax to operate forms with JavaScript

Detailed explanation of the use of AJAX and JavaScript

What is the difference between .min.js and .js files in javascript?

The above is the detailed content of Use js to get the week of the year today is (small example, source code attached). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn