9 Replies Latest reply: Mar 30, 2013 5:32 PM by Adam Cameron. RSS

    DateTimeFormat

    Community Help Community Member
        • 1. Re:  DateTimeFormat
          GavinBaumanis Community Member

          The Format pattern for MINUTES is incorrect.

          Minutes are "NN" not "mm"

          • 2. Re:  DateTimeFormat
            Aaron Neff CommunityMVP

            This function also uses dateFormat and timeFormat masks, except that it uses n to represent minutes (since m represents months). Therefore, for clarity, the description of the mask parameter should probably be:

            -


            Optional. Characters that show how ColdFusion displays a date:

                - d: Day of the month as digits; no leading zero for single-digit days.

                - dd: Day of the month as digits; leading zero for single-digit days.

                - ddd: Day of the week as a three-letter abbreviation.

                - dddd: Day of the week as its full name.

                - m: Month as digits; no leading zero for single-digit months.

                - mm: Month as digits; leading zero for single-digit months.

                - mmm: Month as a three-letter abbreviation.

                - mmmm: Month as its full name.

                - yy: Year as last two digits; leading zero for years less than 10.

                - yyyy: Year represented by four digits.

                - gg: Period/era string.

                - h: hours; no leading zero for single-digit hours (12-hour clock)

                - hh: hours; leading zero for single-digit hours (12-hour clock)

                - H: hours; no leading zero for single-digit hours (24-hour clock)

                - HH: hours; leading zero for single-digit hours (24-hour clock)

                - n: minutes; no leading zero for single-digit minutes

                - nn: minutes; a leading zero for single-digit minutes

                - s: seconds; no leading zero for single-digit seconds

                - ss: seconds; leading zero for single-digit seconds

                - l or L: milliseconds, with no leading zeros

                - t: one-character time marker string, such as A or P

                - tt: multiple-character time marker string, such as AM or PM

             

            The following masks tell how to format the full date and time and cannot be combined with other masks:

                - short: equivalent to m/d/y h:mm tt

                - medium: equivalent to mmm d, yyyy h:mm:ss tt

                - long: medium followed by three-letter time zone; as in, mmmm d, yyyy h:mm:ss tt EST

                - full: equivalent to dddd, mmmm d, yyyy h:mm:ss tt EST

             

            The function also follows Java date time mask. For details, see the section Date and Time Patterns at the following URL: http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

            -


             

            Thanks,

            -Aaron

            • 3. Re:  DateTimeFormat
              Aaron Neff CommunityMVP

              Notes:

               

              1) I wrote "gg: Period/era string." instead of "gg: Period/era string. Ignored. Reserved." b/c "gg" is supported by dateFormat in CF10 (as I've noted in a comment on the dateFormat doc)

              2) "ddd" and "dddd" are broken for dateTimeFormat() in CF10.  The former is currently the same as "dd" w/ 1 additional leading '0'.  The latter is currently the same as "dd" w/ 2 additional leading '0's.  (ex: for Thursday, "ddd" outputs "007" and "dddd" outputs "0007", whereas dateFormat outputs "Thu" and "Thursday" respectively.)  That's a CF10 dateTimeFormat() bug of course.

               

              Thanks,

              -Aaron

              • 4. Re:  DateTimeFormat
                Aaron Neff CommunityMVP

                The uppercase 'S' (Millisecond) Java date time mask pattern letter is broken in CF10.

                 

                Example: #dateTimeFormat(createDateTime(2012, 1, 2, 3, 4, 5), "s:l:S")#

                 

                Expected result: 5:0:0

                 

                Actual result: 5:0:5 (CF10 interprets uppercase 'S' as lowercase 's')

                 

                (I'll get these bugs filed btw. Just noting it here as FYI to others.)

                 

                Thanks,

                -Aaron

                • 5. Re:  DateTimeFormat
                  Adam Cameron. Community Member

                  Sure the link above shouldn't be pointing to an old, obsolete version of Java which CF10 doesn't even run on?  The current docs are here: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html.  They might be exactly the same (I didn't check), but linking to old dead docs is a bit thoughtless, I think

                  • 6. Re:  DateTimeFormat
                    mike causer Community Member

                    I was thinking the same thing!

                    • 7. Re:  DateTimeFormat
                      Aaron Neff CommunityMVP

                      @Adam and @Mike,

                       

                      Good catch and you're exactly right.  I'd copied that URL from another Adobe doc.  But, now I don't know where I'd copied it from.  =P

                       

                      Thanks,

                      -Aaron

                      • 8. Re:  DateTimeFormat
                        cf_chris Community Member

                        Two of the example formats in the docs do NOT work. They are clearly from the Java docs that others linked to. But, they do not give the results you would expect.

                         

                        This:

                         

                         

                        Produces:

                        2012.11.21 AD 'P' 14:53:33 PST

                        02 oc826oc14' PM, Pacific Standard Time

                        • 9. Re:  DateTimeFormat
                          Adam Cameron. Community Member

                          Adobe, are you actually going to sort these docs out? Have you seen the great swathe of comments pointing out its shortcomings? Maybe - like me - you have a Flash blocker, and don't even SEE the comments by default. Why do the comments require Flash? (why, these days, does ANYTHING require Flash?)

                           

                          Other observations: there's no Category, See Also or History sections on this page.

                           

                          --

                          Adam