<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>TIMEFORMAT</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">TIMEFORMAT</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Formats a time value using U.S. English time formatting conventions. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
A custom-formatted time value. If no mask is specified, returns a time value using the hh:mm tt format. For international time formatting, see LSTimeFormat.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
Date and time functions, Display and formatting functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>TimeFormat(time [, mask ])
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
CreateTime, Now, ParseDateTime, LSTimeFormat, DateFormat
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion MX&#160;6.1: Added the mask character L or l to represent milliseconds.
</p>

<p>
ColdFusion&#160;MX: 
</p>
<ul>

<li>Changed the way extra characters are processed: this function processes extra characters within the mask value differently than in earlier releases, as follows: </li>
<ul>

<li>ColdFusion 5 and earlier: the function returns the time format and an apostrophe-delimited list of the extra characters. For example, TimeFormat(Now(),&#160;&quot;hh:mm:ss&#160;dog&quot;) returns 8:17:23&#160;d&#39;o&#39;g.</li>

<li>ColdFusion&#160;MX: the function returns the time format and the extra characters. For example, for the call above, it returns 8:17:23&#160;dog. </li>

<p>
If the extra characters are single-quoted (for example, hh:mm:ss &#39;dog&#39;), ColdFusion 5 and ColdFusion&#160;MX return the time format and the extra characters: 8:17:23&#160;dog.
</p>
    </td>
  </tr></ul>

<li>Added support for the following mask parameter options: short, medium, long, and full. </li>
</ul>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
When passing a date/time value as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object.
</p>

<p>
Database query results for date and time values can vary in sequence and formatting unless you use functions to format the results. To ensure that dates and times display with appropriate formatting, and that users of your ColdFusion application are not confused by dates and times displayed, Macromedia recommends that you use the DateFormat and TimeFormat functions to format date and time values from queries. For more information and examples, see TechNote 22183, "ColdFusion Server (5 and 4.5.x) with Oracle: Formatting Date and Time Query Results," at www.coldfusion.com/Support/KnowledgeBase/SearchForm.cfm. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;cfset todayDate = #Now()#&gt;
&lt;body&gt;
&lt;h3&gt;TimeFormat Example&lt;/h3&gt;
&lt;p&gt;Today's date is &lt;cfoutput&gt;#todayDate#&lt;/cfoutput&gt;.
&lt;p&gt;Using Timeformat, we can display the value in different ways:
&lt;cfoutput&gt;
&lt;ul&gt;
   &lt;li&gt;#TimeFormat(todayDate)#
   &lt;li&gt;#TimeFormat(todayDate, &quot;hh:mm:ss&quot;)#
   &lt;li&gt;#TimeFormat(todayDate, &quot;hh:mm:sst&quot;)#
   &lt;li&gt;#TimeFormat(todayDate, &quot;hh:mm:sstt&quot;)#
   &lt;li&gt;#TimeFormat(todayDate, &quot;HH:mm:ss&quot;)#
&lt;/ul&gt;
&lt;/cfoutput&gt;   
&lt;p&gt;To generate a standard ISO 8601 W3C Date and Time string like 
1997-07-16T19:20, concatenate a DateFormat function, the character T, and a
TimeFormat function.
For example: dateformat(now(), &quot;yyyy-mm-dd&quot;)#T#TimeFormat(now(), &quot;HH:mm:ss&quot;)
produces:&lt;/p&gt;
&lt;cfoutput&gt;#dateformat(now(), &quot;yyyy-mm-dd&quot;)#T#TimeFormat(now(), &quot;HH:mm:ss&quot;)#&lt;/
cfoutput&gt;
&lt;/body&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="TIME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">TIME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A date/time value or string to convert</p>

  </td>
  </tr>
  </table>
</div>
<div id="MASK">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">MASK</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Masking characters that determine the format:</p><ul>

<li>h: hours; no leading zero for single-digit hours (12-hour clock)</li>

<li>hh: hours; leading zero for single-digit hours (12-hour clock)</li>

<li>H: hours; no leading zero for single-digit hours (24-hour clock)</li>

<li>HH: hours; leading zero for single-digit hours (24-hour clock)</li>

<li>m: minutes; no leading zero for single-digit minutes</li>

<li>mm: minutes; a leading zero for single-digit minutes</li>

<li>s: seconds; no leading zero for single-digit seconds </li>

<li>ss: seconds; leading zero for single-digit seconds</li>

<li>l or L: milliseconds. l gives 3 digits. L gives 2 digits.</li>

<li>t: one-character time marker string, such as A or P </li>

<li>tt: multiple-character time marker string, such as AM or PM </li>

<li>short: equivalent to h:mm tt</li>

<li>medium: equivalent to h:mm:ss tt</li>

<li>long: medium followed by three-letter time zone; as in, 2:34:55 PM EST</li>

<li>full: same as long</li>
</ul>


  </td>
  </tr>
  </table>
</div>

  </body>
</html>
