如何从RadDatePicker获取选定的日期和时间

时间:2019-01-19 10:56:10

标签: c#

如何从RadDatePicker(MM / dd / yyyy hh:mm:ss)获取选定的日期和时间?

Response.Write(RadDatePicker1.SelectedDate.Value.ToString())

Response.Write(RadDatePicker1.SelectedDate.Value.ToString())

我知道了

1/17/2019 12:00:00 AM 

代替此:

1/17/2019 12:23:45

2 个答案:

答案 0 :(得分:1)

//从日期选择器中获取当前日期

var date = RadDatePicker1.SelectedDate;

///根据需要使用任何自定义格式设置规则设置日期

var formattedDate = date.ToString("MM/dd/yyyy hh:mm tt");

答案 1 :(得分:0)

RadDatePicker仅在获取使用RadDateTimePicker的日期中显示

标记:

<telerik:RadDateTimePicker x:Name="abc" Grid.Row="19" Grid.Column="1"></telerik:RadDateTimePicker>

代码

var selectedDate = abc.SelectedValue.Value.ToString("MM/dd/yyyy HH:mm:ss");  

ToString after you choices date format than following this link