我迷路了,我可以检查非UTC时间,并且一切正常。但是,当转换为UTC Times时,CFIF不起作用
非UTC {ts'2019-11-10 14:59:46'} LTE {ts'2019-11-10 14:00:00'}
如果是{ts'2019-11-10 21:59:46'} LTE {ts'2019-11-10 21:00:00'}的UTC
我迷路了……似乎无法弄清楚。
<cfset timenow = #Now()#>
<cfset utimenow = dateConvert("Local2UTC", timenow)>
<cfset admintime = #DateAdd("h", -1, chk.stime)#>
<cfset uadmintime = #DateAdd("h", -1, chk.utcact)#>
The chk.stime and chk.utc times are correct. baasically it is taking an hr off time for the cancel window.
These are the time stamps created.
NON UTC {ts '2019-11-10 14:59:46'} LTE {ts '2019-11-10 14:00:00'}
The NonUTC Stamps are time stamps without the UTC Conversions.
UTC if {ts '2019-11-10 21:59:46'} LTE {ts '2019-11-10 21:00:00'}
NonUTC Stamps
<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)>
ColdFusion可以以各种形式保留日期和时间。 eq
,lte
等标准比较会根据各种规则比较变量,如果CF使用错误的变量类型进行比较,则会产生意外结果。
我建议总是在比较日期时使用dateCompare()
...
https://cfdocs.org/datecompare
<cfif utimenow LTE uadmintime>
...
</cfif>
成为
<cfif dateCompare(utimenow, uadmintime) eq -1>
...
</cfif>