Home >Web Front-end >JS Tutorial >How to determine the day of the week with jquery

How to determine the day of the week with jquery

coldplay.xixi
coldplay.xixiOriginal
2020-12-03 09:52:022298browse

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>

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!

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