<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>DATECONVERT</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">DATECONVERT</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>
Converts local time to Coordinated Universal Time (UTC), or UTC to local time. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if required.
</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>
UTC- or local-formatted time object.
</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
</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>DateConvert(&quot;conversion-type&quot;, &quot;date&quot;)
</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>
GetTimeZoneInfo, CreateDateTime, DatePart
</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">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 object as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.
</p>
<table>
  <tr valign="top">
    <td width="30"><strong>Note: </strong></td>
    <td>You can pass the CreateDate or Now function as the date parameter of this function; for example: #DateConvert(CreateDate(2001, 3, 3))#</td>
  </tr>
</table>    </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;h3&gt;DateConvert Example&lt;/h3&gt;
&lt;!--- This shows conversion of current date - time to UTC and back. ---&gt;
&lt;cfset curDate = Now()&gt;
&lt;p&gt;&lt;cfoutput&gt;The current date and time: #curDate#. &lt;/cfoutput&gt;&lt;/p&gt;
&lt;cfset utcDate = DateConvert(&quot;local2utc&quot;, curDate)&gt;
&lt;cfoutput&gt;
   &lt;p&gt;The current date and time converted to UTC time: #utcDate#.&lt;/p&gt; 
&lt;/cfoutput&gt; 
&lt;!--- This code checks whether form was submitted. If so, the code generates 
the CFML date with the CreateDateTime function. ---&gt;  
&lt;cfif IsDefined(&quot;FORM.submit&quot;)&gt;
   &lt;cfset yourDate = CreateDateTime(FORM.year, FORM.month, FORM.day,
FORM.hour,FORM.minute, FORM.second)&gt;
   &lt;p&gt;&lt;cfoutput&gt;Your date value, presented as a ColdFusion date/time
string:#yourdate#.&lt;/cfoutput&gt;&lt;/p&gt;
  &lt;cfset yourUTC = DateConvert(&quot;local2utc&quot;, yourDate)&gt;
   &lt;p&gt;&lt;cfoutput&gt;Your date and time value, converted to Coordinated Universal 
Time
(UTC): #yourUTC#.&lt;/cfoutput&gt;&lt;/p&gt;
   &lt;p&gt;&lt;cfoutput&gt;Your UTC date and time, converted back to local date and time:
#DateConvert(&quot;utc2local&quot;, yourUTC)#.
&lt;/cfoutput&gt;&lt;/p&gt;
&lt;cfelse&gt;
   Type the date and time, and press Enter to see the conversion.
&lt;/cfif&gt;   
&lt;Hr size = &quot;2&quot; color = &quot;#0000A0&quot;&gt;
&lt;form action = &quot;dateconvert.cfm&quot;&gt;
&lt;p&gt;Enter year, month and day in integer format for date value to view:
&lt;table cellspacing = &quot;2&quot; cellpadding = &quot;2&quot; border = &quot;0&quot;&gt;
&lt;tr&gt;
  &lt;td&gt;Year&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;year&quot; value = &quot;1998&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;Month&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;month&quot; value = &quot;6&quot; 
range = &quot;1,12&quot; message = &quot;Enter a month (1-12)&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;Day&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;day&quot; value = &quot;8&quot; 
range = &quot;1,31&quot; 
message = &quot;Enter a day of the month (1-31)&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;Hour&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;hour&quot; value = &quot;16&quot; 
range = &quot;0,23&quot; 
message = &quot;You must enter an hour (0-23)&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;Minute&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;minute&quot; value = &quot;12&quot; 
range = &quot;0,59&quot; 
message = &quot;You must enter a minute value (0-59)&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;Second&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;second&quot; value = &quot;0&quot; 
range = &quot;0,59&quot; 
message = &quot;You must enter a value for seconds (0-59)&quot; 
validate = &quot;integer&quot; required = &quot;Yes&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;input type = &quot;Submit&quot; name = &quot;submit&quot; value = &quot;Submit&quot;&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type = &quot;RESET&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="CONVERSION-TYPE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CONVERSION-TYPE</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>

<ul>

<li>local2Utc: Converts local time to UTC time.</li>

<li>utc2Local: Converts UTC time to local time. </li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="DATE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DATE</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>Date and time string or a variable that contains one. </p>
<p>To create, use CreateDateTime.</p>

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

  </body>
</html>
