Home > Web Front-end > JS Tutorial > How to get today's day of the week code in js

How to get today's day of the week code in js

小云云
Release: 2018-02-24 13:13:37
Original
2670 people have browsed it

This article mainly shares with you how to get today's day of the week code in js. I hope it can help you.

  1.初级方法 
    var week = new Date().getDay(),str='今天是星期';
    if(week === 0){str += '日'}...
    或者switch..
  2.中级方法
  var week = new Date().getDay(), 
      arr = ['日', '一', '二', '三', '四', '五', '六'],
      str = '今天是星期'+arr[week];
  3.高级方法
  var str= '今天是星期'+'日一二三四五六'.charAt(new Date().getDay());
Copy after login

Related recommendations:

JS method of obtaining time

JS method of obtaining time function and extension function

js gets the time and converts between strings and timestamps_javascript skills

The above is the detailed content of How to get today's day of the week code in js. 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