将月份名称转换为整数 [英] Converting month name to integer

查看:180
本文介绍了将月份名称转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上将全月份(1月,9月等)转换为以mm / dd / yyyy格式使用的等效数字。



我可以将我自己的数组放在一起,并将其拉出来,但是必须有一个快速直截了当的方法已经

解决方案

您可以使用格式字符串 MMMM



请参阅自定义DateTime格式字符串 MSDN上。

  Dim fullMonthName为DateTime 
fullMonthName = DateTime.ParseExact (2010年1月26日,dd MMMM yyyy,
CultureInfo.InvariantCulture)


I did a quick search for this and was surprised not to find it anywhere.

Basically looking to convert full month names (January, September, etc) to the equivalent number that would be used in mm/dd/yyyy format.

I can put together my own array and pull it out accordingly, but there has to be a quick and straightforward method already. Right?

解决方案

You can use the format string MMMM for the full name of the month.

See custom DateTime format strings on MSDN.

Dim fullMonthName as DateTime
fullMonthName = DateTime.ParseExact("26 January 2010", "dd MMMM yyyy", 
                                           CultureInfo.InvariantCulture)

这篇关于将月份名称转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆