How to get current time in php code and show using Echo

How to access current time in php website application and show on screen using echo.

In this tutorial we are accessing current time from server and displaying the time using echo method. So here is the complete step by step tutorial for How to get current time in php code and show using Echo.

android-project-download-code-button

How to get current time in php code and show using Echo.

Code for get-time.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<?php

//Getting default TimeZone
$TimeZone = date_default_timezone_get();

//Setting up default timezone to timezone set function.

date_default_timezone_set($TimeZone);


//Showing time on screen using Echo.

echo "Current time is " . date("h:i:s:A");

?>
</body>
</html>

Screenshot:

How to get current time in php code and show using Echo

Click here to download How to get current time in php code and show using Echo project file.

Leave a Reply

Your email address will not be published. Required fields are marked *