我使用 DatePicker 选择日期。所以选择日期后,我应该通过 MessageBox 显示它。我可以显示它,但它是格式 DD / MM / YYYY 。
I am using DatePicker to select the Date. So after selecting the date, I should display it through a MessageBox. I can able to display it but it is in the format DD/MM/YYYY.
以 YYYY-MM-DD 的格式显示它。所以请任何人可以帮助我做的需要。 现在我使用代码显示日期:
And I want to display it in the format YYYY-MM-DD. So please can anyone help me to do the needful. Now I am displaying the date by using the code:
string date1 = datepicker.ValueString; MessageBox.Show(date1);但我可以显示当前日期格式,并根据需要使用代码显示:
But I can display the current date format and display it as required by using code:
string format = "yyyy-MM-dd"; string f = DateTime.Now.ToString(format);因此,请帮助我使用 DatePicker 。
推荐答案我使用代码
<toolkit:DatePicker Name="datepicker" BorderBrush="Transparent" BorderThickness="0" Value="" Background="Transparent" TabNavigation="Cycle" Template="{StaticResource DatePickerControlTemplate1}"/>在CS档案中,我加入了
and in CS file, I added
string format = "yyyy-MM-dd"; string date1 = datepicker.ValueString; DateTime datevalue = DateTime.Parse(date1); string d = datevalue.ToString(format); MessageBox.Show(d);最后我得到了所需的输出和DatePicker的方式,我们必须安装WPtoolkit包
and Lastly I got the required output and By the way for DatePicker we have to install WPtoolkit Package
更多推荐
如何使用C#将日期从DD / MM / YYYY更改为YYYY
发布评论