使用jQuery / JS来确定“每周” [英] Use jQuery/JS to determine the DAY OF WEEK

查看:103
本文介绍了使用jQuery / JS来确定“每周”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用JavaScript或jQuery来确定一周中的几天的方法?例如,如果用户在框中选择的日期是星期日,我可以提醒他们。

Is there a method using either JavaScript or jQuery to determine what day of the week it is? For instance, if the date a user picks in the box is a Sunday, I can alert them.

谢谢

推荐答案

new Date().getDay();  //0=Sun, 1=Mon, ..., 6=Sat

另请参见: MDN上的href =https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date =noreferrer> Javascript Date Object 。

See also: Javascript Date Object on MDN.

注意事项:在浏览器中返回星期几。由于地球不平坦,某些用户的星期几可能与您的服务器的星期几不同。这可能与您的项目有关或可能不相关...

Word of Caution: This returns day of week on the browser. Because the earth is not flat, the day of the week for some users might be different from the day of the week for your server. This may or may not be relevant to your project...

如果您正在做很多日期工作,您可能需要查看JavaScript日期库,如 Datejs Moment.js

If you are doing a lot of date work, you may want to look into JavaScript date libraries like Datejs or Moment.js

这篇关于使用jQuery / JS来确定“每周”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆