⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

System Tools and Time

In PHP, we have a set of functions that do not just handle date formatting, but interact with the system itself and the script execution time. These functions are crucial for code optimization, server overload prevention, and secure file storage.

EXAMPLE
RESULT
The result will be displayed here...

Overview of System Functions

Function Description Example
sleep() Delay in seconds. sleep(2);
usleep() Delay in microseconds. usleep(500000);
hrtime() High-resolution time (nanoseconds). hrtime(true);
uniqid() Generates a unique ID string. uniqid("img_");
time_sleep_until() Sleep until a specified timestamp. time_sleep_until($t);

1. Execution Delay (Sleep & Usleep)

The sleep() and usleep() functions act as a "pause" for your code. They are most commonly used in automated tasks, such as sending emails, where we want to avoid overloading the server.

2. Precise Performance Measurement (hrtime)

hrtime() (High Resolution Time) uses the system clock and returns time in nanoseconds. This is essential for pinpointing which part of your code is slow.

3. Unique Identifier Generation (uniqid)

uniqid() handles unique file naming or session identifiers based on the current time in microseconds, which prevents duplicate names.