如何仅从日期和时间选择器控件中获取月份 [英] how to get only month from dateandtime picker control

查看:253
本文介绍了如何仅从日期和时间选择器控件中获取月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在使用日期和时间选择器控件,并且只想使用这种格式的月份"MMMM",并且我正在使用此代码

hey i am use date and time picker control and i want to only month "MMMM" in this format and i am using this code

dtp_StartDate.Date = Today.ToString("MMMM")


请给我解决方案


pls give me solution

推荐答案

转到Datetime选择器属性

并选择格式"属性,然后自定义在那里写"MMMM"


在Codebehind
Go to the Datetime picker properties

and choose Format property then custom there write there "MMMM"
or

in Codebehind
Datetimepicker1.Format = DateTimePickerFormat.Custom
           Datetimepicker1.Format = "MMM"


试试:
TextBox2.Text = someDate.ToString("MMMM", CultureInfo.CreateSpecificCulture("en-US"));


此处定义的格式的详细信息: MSDN:自定义日期和时间格式字符串 [ ^ ]


Details for the defined format here: MSDN: Custom Date and Time Format Strings[^]


将日期存储到数组字段中,并使用拆分方法.....
store date into array field and use split method.....


这篇关于如何仅从日期和时间选择器控件中获取月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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