Description
Creates a date-time object.
Returns
A date/time value.
CreateDateTime(year, month, day, hour, minute, second)
Introduced in ColdFusion MX6.
CreateDate, CreateTime, CreateODBCDateTime, Now; Evaluation and type conversion issues in Data type conversion in the Developing ColdFusion Applications
Parameter |
Description |
---|---|
year |
Integer in the range 0-9999. Integers in the range 0-29 are converted to 2000-2029. Integers in the range 30-99 are converted to 1930-1999. You cannot specify dates before AD 100. |
month |
Integer in the range 1 (January) - 12 (December) |
day |
Integer in the range 1 - 31 |
hour |
Integer in the range 0 - 23 |
minute |
Integer in the range 0 - 59 |
second |
Integer in the range 0 - 59 |
In Adobe ColdFusion (2016 release), you can use the CreateDateTime function in the following ways:
If you pass the parameter values only partially, other fields take the
<cfscript> // Create date time object and display it WriteOutput(CreateDateTime(2016,2,16,16,45,34) & " | "); // Create object for specified time WriteOutput(#now()#); // Create object for now() </cfscript>
<cfscript> // In ColdFusion (2016 release), you can use the CreateDateTime in the following ways WriteOutput(CreateDateTime(2016) & " | "); WriteOutput(CreateDateTime(2016,6) & " | "); WriteOutput(CreateDateTime(2016,6,10) & " | "); WriteOutput(CreateDateTime(2016,6,10,17) & " | "); WriteOutput(CreateDateTime(2016,6,10,17,45) & " | "); WriteOutput(CreateDateTime(2016,6,10,17,45,38)); </cfscript>
Output
{ts '2016-01-01 00:00:00'} | {ts '2016-06-01 00:00:00'} | {ts '2016-06-10 00:00:00'} | {ts '2016-06-10 17:00:00'} | {ts '2016-06-10 17:45:00'} | {ts '2016-06-10 17:45:38'}