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

How to format a date?

  • July 25, 2016
  • 10 replies
  • 993 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 is closed to new replies. Start a new post to keep the conversation going.

    10 replies

    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

    Thanks, Eddie for all the help. I'll ask them. So, if I want to strip out the time, all I have to do is strip out the space plus the CDT from the field and then convert that to date and then format it the way I want, correct?


    Yes, you can do that, but if time zones are important then look into the function I mentioned.

    Cheers

    Eddie