To get the system boot time in PHP, you can use the exec() function to execute a shell command that retrieves the boot time from the operating system.
Here's the code:
main.php259 chars8 linesThe shell_exec() function runs the uptime -s command, which returns the system boot time in the format YYYY-MM-DD HH:MM:SS. The trim() function is used to remove any extra white space in the output, and the strtotime() function is used to convert the boot time string to a Unix timestamp.
Finally, we print the system boot time in the desired format using the date() function.
gistlibby LogSnag