PHP program to print the timestamp of the start of the request

Here, we are going to learn how to print the timestamp of the start of the request in PHP?
Submitted by Nidhi, on November 24, 2020 [Last updated : March 14, 2023]

$_SERVER[' REQUEST_TIME '] Example

Here, we will use $_SERVER[' REQUEST_TIME '] superglobal, which is used to return the timestamp of the start of the request.

PHP code to print the timestamp of the start of the request

The source code to print the timestamp of the start of the request is given below. The given program is compiled and executed successfully.

<?php
//PHP program to print the timestamp 
//of the start of the request.

$requestTime = $_SERVER['REQUEST_TIME'];

printf("Timestamp: %s<br>", $requestTime);
?>

Output

Timestamp: 1604073329

Explanation

In the above program, we used $_SERVER[REQUEST_TIME'] superglobal that returns the timestamp of the start of the request, which is assigned to the variable $request. After that, we printed the timestamp using printf() on the webpage.

More PHP Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.