Home >Web Front-end >JS Tutorial >How to get today's day of the week code in js
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());
Related recommendations:
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!