Search code examples
datetimecoldfusionmura

ColdFusion - Date and Time formatting is rounding up 5 minutes


I have the following date string:

2017-05-02 08:00:00.0 

When I apply datetimeformat() like:

 #datetimeformat(item.getValue('releasedate'), 'h:mm a')#

It is rounding up by 5 minutes and outputting: 8:05 AM. In the code above, 'releasedate' is the string that is being passed in.

How do I fix this?


Solution

  • Nobody is rounding anything. You are outputting the month here instead of the minutes, and the month happens to be May, so that is 05 with leading zero.

    https://cfdocs.org/datetimeformat:

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

    Minutes are not mm here, but

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