In KRL How can I get the current year, month and day?

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 preliminary block of the rule?

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

The time functions are currently described at http://docs.kynetx.com/docs/Time , but none of them work for what I'm trying to do.

Is there a way to set the time zone when receiving this data?

+3
source share
2 answers

The documents may have been canceled. For convenience, here is the documentation for strftime:

Time: STRFTIME ()

Convert datetime string to another format

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

strftime POSIX strftime.

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

:

time: now()

datetime,

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

: ()

RFC 3339 ( )

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

datetime ISO8601 (v2000).

: ()

( )

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

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

alt text

http://www.statoids.com/tus.html, . , . , .

+4

Source: https://habr.com/ru/post/1782377/


All Articles