Neuron-PHP

RealClock
in package
implements IClock

Real clock implementation using PHP native time functions.

This is the production implementation that uses actual system time.

Table of Contents

Interfaces

IClock
Interface for time/clock operations abstraction.

Methods

date()  : string
Format a timestamp as a date string
microtime()  : string|float
Get current timestamp with microseconds
now()  : DateTimeImmutable
Get current DateTime object
sleep()  : void
Sleep for specified seconds
time()  : int
Get current Unix timestamp
usleep()  : void
Sleep for specified microseconds

Methods

date()

Format a timestamp as a date string

public date(string $format[, int|null $timestamp = null ]) : string
Parameters
$format : string

Date format string

$timestamp : int|null = null

Unix timestamp (null = current time)

Tags
inheritDoc
Return values
string

Formatted date string

microtime()

Get current timestamp with microseconds

public microtime([bool $asFloat = false ]) : string|float
Parameters
$asFloat : bool = false

If true, returns float; otherwise returns string

Tags
inheritDoc
Return values
string|float

Timestamp with microseconds

now()

Get current DateTime object

public now() : DateTimeImmutable
Tags
inheritDoc
Return values
DateTimeImmutable

Current date/time

sleep()

Sleep for specified seconds

public sleep(int $seconds) : void
Parameters
$seconds : int

Number of seconds to sleep

Tags
inheritDoc

time()

Get current Unix timestamp

public time() : int
Tags
inheritDoc
Return values
int

Current timestamp in seconds since Unix epoch

usleep()

Sleep for specified microseconds

public usleep(int $microseconds) : void
Parameters
$microseconds : int

Number of microseconds to sleep

Tags
inheritDoc

        
On this page

Search results