Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 702
Geo Avatar asked Jul 18 '12 21:07

Geo


People also ask

How do I change the date format in ColdFusion?

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.

What is the time format?

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.

How do you format a date?

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.

How do you find the current date in ColdFusion?

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.


1 Answers

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.

like image 150
Henry Avatar answered Oct 19 '22 10:10

Henry