Home > Article > Web Front-end > How to determine the day of the week with jquery
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, '/')】.
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, '/'))); var today = new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); var week = today[day.getDay()]; //最终结果为: alert(week); </script>
As shown in the picture:
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!