JavaScript getUTCMonth() 函数
date.getUTCMonth() -- 返回date对象中用世界标准时间(UTC)表示的月份数(0-11)
- month,中文"月"的意思
- 引用网址:http://www.dreamdu.com/javascript/date.getUTCMonth/
getUTCMonth函数语法
date.getUTCMonth();
getUTCMonth函数返回值
- 返回date对象的月份数(UTC)
- 此值为0(一月)-11(12月)之间的整数
getUTCMonth函数示例
vard=newDate();document.write(d.getUTCMonth());
返回数字形式的月份
vard=newDate();switch(d.getUTCMonth()){case0:{document.write("一月");}break;case1:{document.write("二月");}break;case2:{document.write("三月");}break;case3:{document.write("四月");}break;case4:{document.write("五月");}break;case5:{document.write("六月");}break;case6:{document.write("七月");}case7:{document.write("八月");}break;case8:{document.write("九月");}break;case9:{document.write("十月");}break;case10:{document.write("十一月");}break;case11:{document.write("十二月");}break;default:{document.write("发生错误");}}
使用switch返回中文的月份
varmonthes=newArray("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");month=d.getUTCMonth();document.write("本月是"+monthes[month]);
使用JavaScript数组返回中文的月份
JavaScript getUTCMonth() 函数示例 -- 可以尝试编辑
延伸阅读
- JavaScript getMonth 函数
- JavaScript setUTCMonth 函数