Search code examples
datetimecoldfusiontimestampcoldfusion-9

Time Format - Coldfusion 9


I am trying to create a time stamp in coldfusion that would include milliseconds.

My issue is that I cannot find a code anywhere that would allow me to keep the format consistent by controlling leading zeros.

This is my format:

<cfoutput> 
<cfset todayDate = #Now()#> 
<ul> 
    <li>#TimeFormat(todayDate, "HH:mm:ssl")# </li>
</ul> 
</cfoutput>  

I just need something like "HH:mm:ssll" or some other method that will ensure that I would have a 9 digit timestamp at all times.


Solution

  • Milliseconds with leading zeros?

    <li>
      #TimeFormat(todayDate, "HH:mm:ss")##NumberFormat(TimeFormat(todayDate, "l"),"000")#
    </li>
    

    FYI, l has maximum of 3 digits. So I'm not sure about your 9-digits limit.