Date and Time functions

Date and Time functions v1

No permission to download
Content Author
The Mana World
This script provides functions to easily calculate date and time. More functions might be added in the future.

now()
a shorthand function to get the current time
> returns the number of seconds elapsed since the Unix epoch

now() // => 1497119219 (example, increments every second)





time_from_ms(<delta>)
calculates a Unix timestamp relative to the current time
> returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> ms

time_from_ms(0) // => 1497119219 (example, increments every second)
time_from_ms(+1000) // => 1497119220
time_from_ms(-1000) // => 1497119218





time_from_seconds(<delta>)
calculates a Unix timestamp relative to the current time
> returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> seconds

time_from_seconds(0) // => 1497119219 (example, increments every second)
time_from_seconds(+1) // => 1497119220
time_from_seconds(-1) // => 1497119218





time_from_minutes(<delta>)
calculates a Unix timestamp relative to the current time
> returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> minutes

time_from_minutes(0) // => 1497119219 (example, increments every second)
time_from_minutes(+1) // => 1497119279
time_from_minutes(-1) // => 1497119159





time_from_hours(<delta>)
calculates a Unix timestamp relative to the current time
> returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> hours

time_from_hours(0) // => 1497119219 (example, increments every second)
time_from_hours(+1) // => 1497122819
time_from_hours(-1) // => 1497115619





time_from_days(<delta>)
calculates a Unix timestamp relative to the current time
> returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> days

time_from_days(0) // => 1497119219 (example, increments every second)
time_from_days(+1) // => 1497205619
time_from_days(-1) // => 1497032819





FuzzyTime(<unix timestamp>)
converts a Unix timestamp to a human-readable format
> returns human-friendly relative time

FuzzyTime(0) // => 47 years, 172 days, 18 hours, 52 minutes, and 28 seconds ago
FuzzyTime(time_from_hours(+28)) // => in 1 day and 4 hours




--------------------------------------------------------------------------------------

This script was made by me, for The Mana World + Evol.
L
icense: public domain (CC0)

  • Upvote
Reactions: Envolvents
Author
meko
Downloads
64
Views
2,085
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from meko

  • Randomization helper functions
    Randomization helper functions
    This script provides syntactic sugar for randomization. Works fine with both strings and...
  • Area timer functions
    Area timer functions
    This script provides functions to add (or remove) timers to every player in the area or map.    ...
  • Hash table
    Hash table
    This plugin exposes the internal hash table (strdb) to the script engine to provide a key-value...
  • Array manipulation functions
    Array manipulation functions
    This script provides various array manipulation functions, and more might be added in the...
  • Safe string manipulation functions
    Safe string manipulation functions
    This script provides safe string manipulation functions that do not require PCRE to be enabled...
Back
Top