This is a migrated thread and some comments may be shown as answers.

raddatepicker format date

11 Answers 2811 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
goxel
Top achievements
Rank 1
goxel asked on 03 Mar 2009, 11:07 PM
Hi

İ m using datepicker, i want to format selected date as dd/mm/yyyy. but if day is one digit, zero must come in front of day number. for example if i select 3 may 1999, selected date must be 03/05/1999 not 3/5/1999, how can i do this?

thanx

11 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2009, 05:00 AM
Hello Goxel,

Set the DateFormat to "dd/MM/yyyy" in order to achieve this. See the example below.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" Culture="English (United States)">         
            <DateInput DateFormat="dd/MM/yyyy"
            </DateInput> 
</telerik:RadDatePicker> 
Checkout the link which explains about Formatting Values for RadDatePicker.

Thanks,
Shinu.
0
Lobna
Top achievements
Rank 1
answered on 01 Feb 2014, 04:16 PM
I want to ask if raddatepicker can show Arabic(Hijri) date or not.

Thanks,
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2014, 05:28 AM
Hi Lobna,

As a work around please try the following code snippet.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" Culture="Arabic">
    <DateInput ID="DateInput1" DateFormat="G" DisplayDateFormat="G" runat="server">
    </DateInput>
</telerik:RadDatePicker>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadDatePicker1.DateInput.Culture.DateTimeFormat.Calendar = new GregorianCalendar();
}

Thanks,
Shinu.
0
romulo~
Top achievements
Rank 1
answered on 29 Oct 2014, 08:18 PM
I'm trying to set the dateFormat to dd/MM/yyyy but it changes to dd/MM/yyyy HH:mm when the control loses its focus

I tested these combinations ("dd", "dd/MM", "dd/MM/yy") and they worked fine but with "dd/MM/yyyy" the control add a time part that i don't want...

Is there something i can do? Also I'm not setting cultures.

<telerik:RadDateTimePicker
    ID="dtpDate" runat="server" Width="49.5%"
    DateInput-InvalidStyle-CssClass="invalid"
    DatePopupButton-Visible="true"
    TimePopupButton-Visible="False">
    <DateInput DateFormat="dd/MM/yyyy" />
</telerik:RadDateTimePicker>

0
Kostadin
Telerik team
answered on 03 Nov 2014, 11:52 AM
Hi Romulo,

Could you please setting the DisplayDateFormat as well and let me know about the result?
<DateInput DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy" />

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
romulo~
Top achievements
Rank 1
answered on 03 Nov 2014, 01:59 PM
Hi Kostadin,

The behavior was the same.

I tried setting directly on the control on the page and programatically, but it was the same thing.


I forgot to mention, I'm using the DatetimePicker inside an UserControl, also i'm exposing these properties. Can it be the problem?
0
Kostadin
Telerik team
answered on 06 Nov 2014, 08:49 AM
Hello Romulo,

Could you please provide your mark-up and code behind which represent your current implementation of the control. This might help me replicate the issue locally and provide you with a proper solution.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
romulo~
Top achievements
Rank 1
answered on 10 Nov 2014, 12:59 PM
Hi Kostadin,

Sorry for not posting earlier...

the ascx is like that:

<telerik:RadDateTimePicker
            ID="dtpDateTime" runat="server" Width="100%"
            DatePopupButton-Visible="true" TimePopupButton-Visible="true"
            TimeView-Culture="pt-BR" 
            Calendar-Culture="pt-BR" Calendar-CultureInfo="pt-BR" />


I set the "DateInput.DateFormat" property like this:

public string DateTimeFormat
{
    get { return dtpDateTime.DateInput.DateFormat; }
    set { dtpDateTime.DateInput.DateFormat = value; }
}

I also tried the DisplayDateFormat property with this, but the behavior didn't change

The string is based on the formats available on the documentation, for example: "dd/MM/yyyy", "HH:mm", but as mentioned before, the format "dd/MM/yyyy" that I was planning for default makes it appears like "dd/MM/yyyy HH:mm:ss" but other string formats are OK

I also tried removing that culture properties, but I don't think they are the problem... (also, I'm setting tooltips and localization strings in some properties in the ascx part, but again, I don't think they are the problem too).

Thanks



0
Brian
Top achievements
Rank 1
answered on 12 Nov 2014, 03:51 PM
I have basically the same question/issue.   I have a datetimepicker that in some cases I dont want the time portion to be displayed - meaning i only want to see the format "dd/MM/yyyy".   Every time I set the DateFormat and DisplayDateFormat to this it formats the date as intended but always still shows the time portion.  So really what I'm wondering is - is there a way to format the DisplayDate so it does not show the time?
0
Kostadin
Telerik team
answered on 13 Nov 2014, 09:31 AM
Hi Romulo,

I examine the provided code and I was unable to find the part where you set the DisplayDateFormat property. You need to set this property as well in order to display the chosen format in the input element. Please check out the following code snippet.
public string DateTimeFormat
    {
        get {
            return dtpDateTime.DateInput.DateFormat;
        }
        set {
            dtpDateTime.DateInput.DateFormat = value;
            dtpDateTime.DateInput.DisplayDateFormat = value;
        }
    }

Hi Brian,

I am afraid I am still not able to replicate the issue locally when both properties are set.
I would appreciate if you can provide the code of a small sample in order to investigate the issue locally. Here I attached a small runnable sample based on the Romulo code which work correctly on my end. You can try replicate the issue in the sample and just let me know what I should change.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brian
Top achievements
Rank 1
answered on 13 Nov 2014, 05:18 PM
Thanks for your example...  I managed to get it working.   I am adding the DTP to the panel programmatically and I was setting the format before adding it..  I discovered that for some reason I have to add the object to the panel, and then set the format. 
Tags
Calendar
Asked by
goxel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Lobna
Top achievements
Rank 1
romulo~
Top achievements
Rank 1
Kostadin
Telerik team
Brian
Top achievements
Rank 1
Share this question
or