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

How to determine the day of the week with jquery

coldplay.xixi
Release: 2023-01-04 09:36:26
Original
2252 people have browsed it

Jquery method to determine the day of the week: first enter the digital date; then perform regular conversion judgment, the code is [var date = "07/17/2014";var day = new Date(Date.parse( date.replace(/-/g, '/')】.

How to determine the day of the week with jquery

The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.

Jquery method to determine the day of the week:

 <script type="text/javascript">                        
 var date = "07/17/2014";    //此处也可以写成 17/07/2014 一样识别    也可以写成 07-17-2014  但需要正则转换 
 var day = new Date(Date.parse(date));   //需要正则转换的则 此处为 : var day = new Date(Date.parse(date.replace(/-/g, &#39;/&#39;)));
 var today = new Array(&#39;星期日&#39;,&#39;星期一&#39;,&#39;星期二&#39;,&#39;星期三&#39;,&#39;星期四&#39;,&#39;星期五&#39;,&#39;星期六&#39;);
 var week = today[day.getDay()];
 
//最终结果为:
 
alert(week);
</script>
Copy after login

As shown in the picture:

How to determine the day of the week with jquery

Relevant learning recommendations: javascript video tutorial

The above is the detailed content of How to determine the day of the week with jquery. 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!