Documentation
TebexDiscordYouTubeGitHub
  • Introduction
  • FIVEM FREE RESOURCES
    • BDSC
      • Guides
        • Core Setup
          • Installing BDSC
          • Configuring BDSC
        • Plugin Development
          • What is a Plugin?
          • Plugin Structure
          • Extending Player Objects
      • API
        • Functions
          • Player
          • Server
          • Client
          • Shared
        • Modules
          • Player Manager
          • Buckets
          • Plugins
        • UI Components
    • boii_utils
      • Installation
      • Configuration
      • Modules
      • API
        • Callbacks
        • Characters
        • Commands
        • Cooldowns
        • Debugging
        • Entities
        • Environment
        • Framework Bridge
        • Geometry
        • Items
        • Keys
        • Licences
        • Maths
        • Methods
        • Player
        • Requests
        • Strings
        • Tables
        • Timestamps
        • UI Bridges
        • Vehicles
        • Version
        • XP
        • UI Elements
  • FIVEM PAID RESOURCES
    • Page 2
Powered by GitBook
On this page
  • Accessing the Module
  • Server
  • get_timestamp()
  • convert_timestamp(timestamp)
  • get_current_date_time()
  • add_days_to_date(date, days)
  • date_difference(start_date, end_date)
  • convert_timestamp_ms(timestamp_ms)
  1. FIVEM FREE RESOURCES
  2. boii_utils
  3. API

Timestamps

Provides utility functions for working with date, time, and UNIX timestamps.


Accessing the Module

local TIMESTAMPS <const> = exports.boii_utils:get("modules.timestamps")

Server

get_timestamp()

Gets the current UNIX timestamp and its formatted string.

Returns

Name
Type
Description

timestamp

number

Current UNIX timestamp

formatted

string

Formatted date-time string

Example

local time = TIMESTAMPS.get_timestamp()
print(time.timestamp)  -- 1700000000
print(time.formatted)  -- "2025-03-29 18:00:00"

convert_timestamp(timestamp)

Converts a UNIX timestamp to a readable date and time.

Parameters

Name
Type
Description

timestamp

number

UNIX timestamp to convert

Returns

Name
Type
Description

date

string

Date in YYYY-MM-DD

time

string

Time in HH:MM:SS

both

string

Full datetime string

Example

local result = TIMESTAMPS.convert_timestamp(os.time())
print(result.both) -- "2025-03-29 18:00:00"

get_current_date_time()

Gets the current full date and time information.

Returns

Name
Type
Description

timestamp

number

UNIX timestamp

date

string

YYYY-MM-DD

time

string

HH:MM:SS

both

string

Full formatted string

Example

local now = TIMESTAMPS.get_current_date_time()
print(now.date, now.time)

add_days_to_date(date, days)

Adds days to a given date.

Parameters

Name
Type
Description

date

string

Base date in YYYY-MM-DD

days

number

Number of days to add

Returns

Type
Description

string

New date in YYYY-MM-DD

Example

local new_date = TIMESTAMPS.add_days_to_date("2025-03-29", 7)
print(new_date) -- "2025-04-05"

date_difference(start_date, end_date)

Calculates the number of days between two dates.

Parameters

Name
Type
Description

start_date

string

Start date YYYY-MM-DD

end_date

string

End date YYYY-MM-DD

Returns

Name
Type
Description

days

number

Absolute difference in days

Example

local diff = TIMESTAMPS.date_difference("2025-03-01", "2025-03-29")
print(diff.days) -- 28

convert_timestamp_ms(timestamp_ms)

Converts a millisecond-based UNIX timestamp to human-readable format.

Parameters

Name
Type
Description

timestamp_ms

number

UNIX timestamp in milliseconds

Returns

Name
Type
Description

date

string

YYYY-MM-DD

time

string

HH:MM:SS

both

string

Full formatted string

Example

local readable = TIMESTAMPS.convert_timestamp_ms(1700000000000)
print(readable.both) -- "2025-03-29 18:00:00"
PreviousTablesNextUI Bridges

Last updated 2 months ago