...
time:now() - returns the current date based upon the user's location dataand time based on a time zone.
Code Block | ||||
---|---|---|---|---|
| ||||
xTime = time:now() # 2010-10-06T18:11:47Z xTime = time:now({ # 2010-10-06T18:11:47Z "tz" : "America/Los_Angeles" }) |
...
time:new() - returns a new RFC 3339 datetime string () from a string formatted as described in ISO8601 (v2000).
Code Block | ||||
---|---|---|---|---|
| ||||
time:new("2010-08-08") # 2010-08-08T00:00:00Z (Date only—defaults to 00:00) time:new("67342") # NOT SUPPORTED YET # 1967-12-08T00:00:00Z (Year DayOfYear) time:new("2011W206T1345-0600") # 2011-05-21T19:45:00Z (Year WeekOfYear DayOfWeek) time:new("083023Z") # 2010-10-05T08:30:23Z (Time only—defaults to today) |
...
time:add() - adds (or subtracts) a specific number of time units to a source string, assuming the default time zone.
Code Block | ||||
---|---|---|---|---|
| ||||
time:add("2011W206T1345-0600",{"days": -65}) # 2011-03-17T13:45:00Z time:add("2010-08-08",{"weeks": 5}) # 2010-09-12T00:00:00Z time:add("67342",{"hours": 3}) # NOT SUPPORTED YET # 1967-12-08T04:00:00Z time:add("083023Z",{"minutes": 10}) # 2010-10-06T08:40:23Z time:add("083023Z",{"seconds": 632}) # 2010-10-06T08:40:55Z time:add("1970-01-01",{"seconds": 1286388924}) # 2010-10-06T18:15:24Z |
The exact rules can get complicated considering leap years, different month lengths, daylight savings time, and adding (or subtracting) multiple units at once versus one after another. See http://momentjs.com/docs/#/manipulating/add/ (the time module uses a version above 2.18.0).
time:strftime()
time:strftime() - returns a datetime string in a specified format following POSIX strftime conventions.
...