我正在开发一个应用程序,需要获取当前的年、月和日。有没有办法在规则的前块中获取此信息?
我可以以字符串或数字或两者的形式获取此数据吗?
目前有时间函数记录在http://docs.kynetx.com/docs/Time http://docs.kynetx.com/docs/Time但它们似乎都不适合我想做的事情。
有没有办法在获取这些数据时设置时区?
我可以使用 strftime 来完成此操作,这似乎是一个未记录的功能,因此请谨慎使用。
ruleset a60x518 {
meta {
name "date-test"
description <<
date-test
>>
author "Mike Grace"
logging on
}
rule testing {
select when pageview ".*"
pre {
retTime = time:strftime(time:now({"tz":"America/Denver"}), "%c");
month = time:strftime(time:now({"tz":"America/Denver"}), "%B");
year = time:strftime(time:now({"tz":"America/Denver"}), "%Y");
day = time:strftime(time:now({"tz":"America/Denver"}), "%d");
}
{
notify("time",retTime) with sticky = true;
notify("month",month) with sticky = true;
notify("year",year) with sticky = true;
notify("day",day) with sticky = true;
}
}
}
应用程序在 example.com 上运行两次。一次将时区设置为纽约,另一次设置为丹佛
我用过这个网站http://www.statoids.com/tus.html http://www.statoids.com/tus.html获取用于时区的正确字符串。我不知道它们是否都有效。我刚刚找到这个网站并尝试了一些,它们有效,所以请谨慎使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)