Home > Web Front-end > JS Tutorial > body text

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

亚连
Release: 2018-05-18 15:48:09
Original
2868 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!