Skip to main content
2Charlie
Inspiring
July 25, 2016
Question

How to format a date?

  • July 25, 2016
  • 1 reply
  • 962 views

I have tried the following for formatting a date.

#DateFormat(cfData.data.date_modified, "mm/dd/yyyy")#

This above formatting shows this Error in custom script instead. This is what the date looks like: 07/20/2016 2:48 pm CDT

    This topic has been closed for replies.

    1 reply

    EddieLotter
    Inspiring
    July 25, 2016

    Put the following in the ColdFusion script, above the problem line, which is line 3 below:

    #DateFormat(createDateTime(2016, 7, 20, 14, 48, 0), "mm/dd/yyyy")#
    <cfdump var="#cfData.data.date_modified#">
    #DateFormat(cfData.data.date_modified, "mm/dd/yyyy")#

    Then show us a screen capture of the result.

    Cheers
    Eddie

    2Charlie
    2CharlieAuthor
    Inspiring
    July 25, 2016

    Thanks for the response. This is what it shows.

    Here's the code:

    <h6>Modify Date: #DateFormat(createDateTime(2016, 7, 20, 14, 48, 0), "mm/dd/yyyy")#</h6>

    This is the dump:<cfdump var="#cfData.data.date_modified#">

    <h6>Line 3: #DateFormat(cfData.data.date_modified, "mm/dd/yyyy")#</h6>

    EddieLotter
    Inspiring
    July 25, 2016

    Okay, let's have a look at each piece. Show us the result of the following:

    <cfdump var="#i#">

    <cfdump var="#cfData#">

    <cfdump var="#cfData.data#">

    #DateFormat(cfData.data.date_modified, "mm/dd/yyyy")#

    Cheers

    Eddie