本文介绍了获取月份名称而不是数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery datepicker插件.我可以通过

I am using the jQuery datepicker plugin. I can get the month number by

$("#datepicker").datepicker('getDate').getMonth()+1

如何直接获取月份名称(即不使用switch case)?

How can I get the month name directly (i.e. without using a switch case)?

推荐答案

如果您想要一个简单的解决方案,就是这样:

If you want a simple solution this is it:

var months = [ "January", "February", "March", "April", "May", "June",
               "July", "August", "September", "October", "November", "December" ];

var selectedMonthName = months[$("#datepicker").datepicker('getDate').getMonth()];


一种更复杂但更可定制的方法是使用格式化程序(我的评论).然后,请参见此问题和答案.

这篇关于获取月份名称而不是数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:03
查看更多