在 KRL 中,如何获取当前的年、月和日? [英] In KRL How can I get the current year, month, and day?

查看:37
本文介绍了在 KRL 中,如何获取当前的年、月和日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我需要在其中获取当前的年、月和日.有没有办法在规则的预块中获取这些信息?

I am working on an application in which I need to get the current year, month, and day. Is there a way to get this information in the pre block of a rule?

我可以以字符串或数字或两者的形式获取这些数据吗?

Can I get this data as a string or a number or both?

目前在 http://docs.kynetx.com/docs/Time 上记录了时间函数a> 但它们似乎都不适用于我正在尝试做的事情.

There are currently time functions documented on http://docs.kynetx.com/docs/Time but none of them seem to work for what I am trying to do.

有没有办法在获取这些数据时设置时区?

Is there a way to set the timezone when getting this data?

推荐答案

也许文档被还原了.为方便起见,这里是 strftime 的文档:

Perhaps the docs got reverted. For convenience, here is the documentation for strftime:

时间:strftime()

将日期时间字符串转换为不同的格式

Convert a datetime string to a different format

Usage
    time:strftime(`<string>`,`<format>`)    

strftime 的有效格式参数遵循 POSIXstrftime 约定.

Valid format arguments to strftime follow the POSIX strftime conventions.

示例

time:strftime(xTime,"%F %T")                 # 2010-10-06 18:15:24         
time:strftime(xTime,"%F")                    # 2010-10-06         
time:strftime(xTime,"%T")                    # 18:19:29         
time:strftime(xTime,"%A %d %b %Y")           # Wednesday 06 Oct 2010
time:strftime(xTime,"%c")                    # Oct 6, 2010 6:25:55 PM

其他时间函数:

时间:现在()

基于用户位置数据的当前日期时间

Current datetime based upon user’s location data

Usage    
    time:now()
    time:now({"tz" : <timezone>) 

time:new()

从字符串创建一个新的 RFC 3339 日期时间字符串(允许在源字符串的格式方面有一定的灵活性)

Create a new RFC 3339 datetime string from a string (allows some flexibility in how the source string is formatted)

Usage 
    time:new()                     # Equivalent to time:now()
    time:new(<string>)   

日期时间源字符串的有效格式可以在 ISO8601 (v2000) 中找到.

Valid formats for the datetime source string can be found in ISO8601 (v2000).

time:add()

向源字符串添加(或减去)特定数量的时间单位

Add (or subtract) a specific number of time units to a source string

Usage  
    time:add(<string>,{<unit> : n})  

这篇关于在 KRL 中,如何获取当前的年、月和日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆