CFLib.org – Common Function Library Project

MySQLDT2TS(dt)

Last updated June 27, 2002

Version: 1 | Requires: ColdFusion 5 | Library: DatabaseLib

 
Rated 0 time(s). Average Rating: 0

Description:
Converts the passed CF datetime into a MySQL timestamp.

Return Values:
Returns a string.

Example:

view plain print about
<CFOUTPUT>
The current time in MySQL timestamp: 
#MySQLDT2TS(Now())#<BR>
<I>(Note - due to page caching, the time value will not change.)</I>
</CFOUTPUT>

Parameters:

Name Description Required
dt Date object. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Converts a CF DateTime object into a MySQL timestamp.
 * 
 * @param dt      Date object. (Required)
 * @return Returns a string. 
 * @author Mark Andrachek (hallow@webmages.com) 
 * @version 1, June 27, 2002 
 */

function MySQLDT2TS(dt) {
    return Year(dt) & NumberFormat(Month(dt),'00') & NumberFormat(Day(dt),'00') & NumberFormat(Hour(dt),'00') & NumberFormat(Minute(dt),'00') & NumberFormat(Second(dt),'00');
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
4 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson