locked
DateTimePicker control - CustomFormat "R" RRS feed

  • Question



  • I am getting "r" displayed in DatetimePicker when i set the  customFormat of DatetimePicker 's object .

    why i am getting it ???

    _dtp1.customeformat="r";

    or is there anything like         :    SOME_FUNCTION("r")  giving me ===>> ddd, dd MMM yyyy HH':'mm':'ss 'GMT'

    I am expecting date i following format : 

    Thu, 10 Apr 2008 13:30:00 GMT  
    • Edited by khannaB7 Tuesday, June 12, 2012 9:16 AM
    Tuesday, June 12, 2012 8:07 AM

Answers

  • well i got the solution :

    DateTimeFormatInfo myDTFI = DateTimeFormatInfo.CurrentInfo;

    _calendar.format =  DateTimePickerFormat.Custom;

    _calendar.CustomFormat = myDTFI.GetAllDateTimePatterns("r")[0];

    this wud show the DateTime in "r" format.

    • Marked as answer by khannaB7 Thursday, June 14, 2012 4:01 AM
    Tuesday, June 12, 2012 11:11 AM

All replies

  • Wherefrom did you get the idea that "r" will result in your expected format ?

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, June 12, 2012 8:16 AM
  • aint 'r' is the format specifier for RFC1123 format for DateTimePicker ??
    Tuesday, June 12, 2012 8:51 AM
  • The problem for the Datetimepicker is that it provides 4 version of format ( long,short,time and custom ). The "r,R" format specifier is a Standard Date and Time Format String but if you want to use custom format you are limited to the Custom Date and Time Format Strings.

    Maybe this project on CodeProject can help you to get your desired result: http://www.codeproject.com/Articles/45684/Culture-Aware-Month-Calendar-and-Datepicker

    Yes, i know it is C# and it is about CultureInfo, but meybe it can help you.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/


    • Edited by Heslacher Tuesday, June 12, 2012 9:31 AM
    Tuesday, June 12, 2012 9:31 AM
  • well i got the solution :

    DateTimeFormatInfo myDTFI = DateTimeFormatInfo.CurrentInfo;

    _calendar.format =  DateTimePickerFormat.Custom;

    _calendar.CustomFormat = myDTFI.GetAllDateTimePatterns("r")[0];

    this wud show the DateTime in "r" format.

    • Marked as answer by khannaB7 Thursday, June 14, 2012 4:01 AM
    Tuesday, June 12, 2012 11:11 AM
  • Great you have solved it. So please mark your last post as answer so that other users who have the same issue can find an answer.

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Wednesday, June 13, 2012 3:13 PM