The getdate(), localtime(), and gettimeofday() functions retrieve current date and time details in PHP, including microsecond precision.
getdate() → human-readable componentslocaltime(time(), true) → low-level arraygettimeofday() → seconds + microseconds
// Fetch current date and time as an associative array
<?php
$date_info = getdate();
print_r($date_info);
?>
This outputs year, month, day, weekday, hours, minutes, and seconds.
// Retrieve raw local time values using current timestamp
<?php
$local_time = localtime(time(), true);
print_r($local_time);
?>
The array includes seconds, minutes, hours, and date offsets.
// Get precise time including microseconds
<?php
$time_info = gettimeofday();
print_r($time_info);
?>
Useful for benchmarking and performance measurements.
Real-time high-precision clock simulation:
getdate() for readable output.gettimeofday() for precision.date() for formatting.getdate().localtime().gettimeofday().