当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jQuery简单实现根据日期计算星期几的方法

jQuery简单实现根据日期计算星期几的方法

2019年05月30日  | 移动技术网IT编程  | 我要评论

本文实例讲述了jquery简单实现根据日期计算星期几的方法。分享给大家供大家参考,具体如下:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>www.jb51.net jquery根据日期算周次</title>
</head>
<body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(function() {
  function ddd(types) {
    var text = "";
    switch(types) {
      case 1:
        text = "星期一";
        break;
      case 2:
        text = "星期二";
        break;
      case 3:
        text = "星期三";
        break;
      case 4:
        text = "星期四";
        break;
      case 5:
        text = "星期五";
        break;
      case 6:
        text = "星期六";
        break;
      case 7:
        text = "星期日";
        break;
      default:
    }
    return text;
  }
  var date = "2019-1-9"; 
  var day = new date(date.parse(date));
  var today = new array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
  var week = today[day.getday()];
  //最终结果为:
  console.log(week);
})
</script>
</body>
</html>

这里使用在线html/css/javascript代码运行工具:测试上述代码,可得如下运行结果:

ps:这里再为大家推荐几款时间及日期相关工具供大家参考使用:

在线日期/天数计算器:

在线日期计算器/相差天数计算器:

在线日期天数差计算器:

unix时间戳(timestamp)转换工具:

更多关于jquery相关内容感兴趣的读者可查看本站专题:《jquery日期与时间操作技巧总结》、《jquery扩展技巧总结》、《jquery常见事件用法与技巧总结》、《jquery常用插件及用法总结》、《jquery常见经典特效汇总》及《jquery选择器用法总结

希望本文所述对大家jquery程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网