登录

用户名:

密码:
MySQLDT2TS(dt)     
作者:nsr131421
发部日期:Tue, 04/17/2007

将一个CF时间对象转换为MYSQL的时间戳

<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>

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

最后更新:Tue, 04/17/2007