ColdFusion UTC TIME LTE 检查与非 UTC 时间
ColdFusion UTC TIME LTE Checks vs NonUTC Time
我迷路了,我可以检查一下非 UTC 时间,一切正常。
但是当转换为 UTC 时间时,CFIF 不起作用
非 UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
我迷路了...似乎无法弄清楚。
<cfset timenow = #Now()#>
<cfset utimenow = dateConvert("Local2UTC", timenow)>
<cfset admintime = #DateAdd("h", -1, chk.stime)#>
<cfset uadmintime = #DateAdd("h", -1, chk.utcact)#>
chk.stime 和 chk.utc 时间是正确的。基本上取消需要一个小时的休息时间 window.
这些是创建的时间戳。
NON UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
NonUTC 时间戳是没有 UTC 转换的时间戳。
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
非UTC邮票
<cfif timenow LTE admintime>
This one works fine...
NON UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
Then allow cancel
<cfelse>
This cfelse is activated properly and Can't Cancel.
Can't Cancel
</cfif>
UTC Stamps
<cfif utimenow LTE uadmintime>
This one does not work
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
Then allow cancel
This UTC Time does not activate properly and allows the cancel.
Executes/Activates inside the cfif - it should not
<cfelse>
Can't Cancel
</cfif>
我也尝试过转换以确保 ODBCTime
<cfset uadmintime = createODBCDateTime(uadmintime)>
我最终不得不重新创建时间,并比较该格式。
它现在可以与 <cfif timenow LTE admintime>
和 DateCompare
一起使用,如下所示。这一定是不喜欢 {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
格式的格式问题。
<cfset nctime = '#dateformat(uadmintime, "dd-MM-yyyy")# #timeformat(uadmintime, "hh:mm:ss")#'>
<cfset nutctime = '#dateformat(utimenow, "dd-MM-yyyy")# #timeformat(utimenow, "hh:mm:ss")#'>
ColdFusion 是一种松散类型的语言,可以将 date/time 值保存在各种数据类型中。 eq
、lte
等标准比较根据未知和不断变化的规则比较不同类型的变量,因此如果 CF 决定转换为不同的数据类型,可能会产生意想不到的结果。有时您会期望一个变量是一个 date/time 对象,而实际上它是一个通过日期验证的字符串。不同版本的 CF、Lucee 等可能会有所不同,或者也取决于所涉及的实际值。
我建议 总是 在比较日期时使用 dateCompare()
...
https://cfdocs.org/datecompare
<cfif utimenow LTE uadmintime>
...
</cfif>
变成
<cfif dateCompare(utimenow, uadmintime) lte 0>
...
</cfif>
示例代码:
我迷路了,我可以检查一下非 UTC 时间,一切正常。 但是当转换为 UTC 时间时,CFIF 不起作用
非 UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
我迷路了...似乎无法弄清楚。
<cfset timenow = #Now()#>
<cfset utimenow = dateConvert("Local2UTC", timenow)>
<cfset admintime = #DateAdd("h", -1, chk.stime)#>
<cfset uadmintime = #DateAdd("h", -1, chk.utcact)#>
chk.stime 和 chk.utc 时间是正确的。基本上取消需要一个小时的休息时间 window.
这些是创建的时间戳。
NON UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
NonUTC 时间戳是没有 UTC 转换的时间戳。
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
非UTC邮票
<cfif timenow LTE admintime>
This one works fine...
NON UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
Then allow cancel
<cfelse>
This cfelse is activated properly and Can't Cancel.
Can't Cancel
</cfif>
UTC Stamps
<cfif utimenow LTE uadmintime>
This one does not work
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
Then allow cancel
This UTC Time does not activate properly and allows the cancel.
Executes/Activates inside the cfif - it should not
<cfelse>
Can't Cancel
</cfif>
我也尝试过转换以确保 ODBCTime
<cfset uadmintime = createODBCDateTime(uadmintime)>
我最终不得不重新创建时间,并比较该格式。
它现在可以与 <cfif timenow LTE admintime>
和 DateCompare
一起使用,如下所示。这一定是不喜欢 {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
格式的格式问题。
<cfset nctime = '#dateformat(uadmintime, "dd-MM-yyyy")# #timeformat(uadmintime, "hh:mm:ss")#'>
<cfset nutctime = '#dateformat(utimenow, "dd-MM-yyyy")# #timeformat(utimenow, "hh:mm:ss")#'>
ColdFusion 是一种松散类型的语言,可以将 date/time 值保存在各种数据类型中。 eq
、lte
等标准比较根据未知和不断变化的规则比较不同类型的变量,因此如果 CF 决定转换为不同的数据类型,可能会产生意想不到的结果。有时您会期望一个变量是一个 date/time 对象,而实际上它是一个通过日期验证的字符串。不同版本的 CF、Lucee 等可能会有所不同,或者也取决于所涉及的实际值。
我建议 总是 在比较日期时使用 dateCompare()
...
https://cfdocs.org/datecompare
<cfif utimenow LTE uadmintime>
...
</cfif>
变成
<cfif dateCompare(utimenow, uadmintime) lte 0>
...
</cfif>
示例代码: