3 Replies Latest reply on Feb 28, 2008 8:25 AM by RossRitchey

    DateField Format

    RossRitchey Level 4
      Alright, I've done some searching, but cannot find an answer to my question.

      I am using a dateField and I want the date to display like this "28/Feb/2008"

      I currently have the formatDate=DD/MM/YYYY which displays "28/02/2008"
      If I change the formatDate to DD/MMM/YYYY it displays "28/02022008"
      If I change the formatDate to DD/M/YYYY it displays "28/022008"

      How do I get a text for the month?
        • 1. Re: DateField Format
          RossRitchey Level 4
          Wow, all of 20 minutes after I post, I find the answer on another website.

          http://www.cubicleman.com/2008/02/12/flex-datefield-and-formats/

          Apparantly you need to use a dateFormatter component, and create a function that tells the dateFormatter to format the date instead of the normal parse. Perhaps this is a bug in the dateField component?
          • 2. Re: DateField Format
            ericbelair Level 1
            "MMM" seems to work fine for me. Here is my code:

            var dateString:String = "09-13-1978";

            var formatMask:String = "DD/MMM/YYYY";

            var dateFormatter:DateFormatter = new DateFormatter;

            dateFormatter.formatString = formatMask;

            var formattedDate:String = dateFormatter.format(dateString);

            This gives me "13/Sep/1978".

            Not sure where your's is going wrong. Show us more of your code....

            Thanks.
            • 3. Re: DateField Format
              RossRitchey Level 4
              The code that did not work is this:

              <mx:DateField id="Date2" formatDate="DD/MMM/YYYY">

              As you can see, I was not using any scripting at all, attempting to do this purely in the mxml declaration of the object. But this formatDate displays "28/02022008" for todays date, when I would assume it would display "28/Feb/2008"

              The scripting method, using a dateFormatter works fine.