- Loading the Timestamp Library
- Method chaining
- Supported operators
- Supported methods
- Constructor
- Timestamp:now()
- Timestamp:today()
- Timestamp:yesterday()
- Timestamp:tomorrow()
- Timestamp:timezoneOffset()
- Timestamp:toHuman()
- Timestamp:toUtc()
- Timestamp:format()
- Timestamp:addSeconds()
- Timestamp:subSeconds()
- Timestamp:addMinutes()
- Timestamp:subMinutes()
- Timestamp:addHours()
- Timestamp:subHours()
- Timestamp:addDays()
- Timestamp:subDays()
- Timestamp:addMonths()
- Timestamp:subMonths()
- Timestamp:addYears()
- Timestamp:subYears()
- Timestamp:isFuture()
- Timestamp:isPast()
- Timestamp:isNow()
- Timestamp:diffInSeconds()
- Timestamp:diffInMinutes()
- Timestamp:diffInHours()
- Timestamp:diffInDays()
The Timestamp library is optional. In order to use this library, you must require it in one of your source files (preferably main.lua) prior to use. It only needs to be required once in a single file. It is recommended you do this at the top of your main.lua file, outside of any functions or other code, and you may do this by using this code:
The Timestamp class supports method chaining, but does not modify the base object unless explicitly stated. That is, most functions will return a new Timestamp object with the modification made.
Creates a Timestamp object out of an arbitrarily defined date and time. Any field that is
You may also pass a UNIX timestamp.
Returns a Timestamp object that contains the current date/time value of your computer's clock.
Returns a Timestamp object that contains the current date with time starting at 12:00AM.
Exactly like Timestamp:today() except it is for yesterday's date/time.
Exactly like Timestamp:today() except it is for tomorrow's date/time.
Returns your offset, in hours, from UTC.
Returns the timestamp as a human-readable string and (optionally) including tzOffset to represent the timezone's offset from the prime meridian. If tzOffset is not given, the time will be using local time. tzOfset = 0 will return time in UTC.
Returns the timestamp as a human-readable string in UTC format. For example: Thu, 01 Jan 1970 00:00:00 UTC
Returns the timestamp in any format requested, using standard ANSI C date/time formatting options.
Returns a new Timestamp object with 'sec' seconds added on.
Returns a new Timestamp object with 'sec' seconds subtracted.
Returns a new Timestamp object with 'min' minutes added on.
Returns a new Timestamp object with 'min' minutes subtracted.
Returns a new Timestamp object with 'hours' hours added on.
Returns a new Timestamp object with 'hours' hours subtracted.
Returns a new Timestamp object with 'days' days added on.
Returns a new Timestamp object with 'days' days subtracted.
Returns a new Timestamp object with 'months' months added on.
Returns a new Timestamp object with 'months' months subtracted.
Returns a new Timestamp object with 'years' years added on.
Returns a new Timestamp object with 'years' years subtracted.
Returns
Returns
Returns
Returns the number of seconds between two timestamps. This number may be negative if 'other' is in the future in relation to the original timestamp.
This is the same as the - operator.
Exactly like Timestamp:diffInSeconds() except it returns the difference in full minutes.
Exactly like Timestamp:diffInSeconds() except it returns the difference in full hours.
Exactly like Timestamp:diffInSeconds() except it returns the difference in full days.
Page last updated at 2018-10-02 21:54:50