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.
Hence, dateformat(now(), "mm-D-yyyy") is the same as dateformat(now(), "mm-d-yyyy") when flag is set to true. By default Capital D is used to specify Day of the year. See example below. ColdFusion (2018 release) Update 3.
As of ISO 8601-1:2019, the basic format is T[hh][mm][ss] and the extended format is T[hh]:[mm]:[ss]. Earlier versions omitted the T (representing time) in both formats. [hh] refers to a zero-padded hour between 00 and 24. [mm] refers to a zero-padded minute between 00 and 59.
Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.
Use the Now() function to obtain the current date and time from the server. Continuing onward, we can customize the date format even more by specifying a mask in the DateFormat() function. The TimeFormat() function is similar to DateFormat(), except, of course, that it returns the time.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With