PHP MySQL Select Time from Timestamp Example
Feb 24, 2022 . Admin
Hello Friends,
I am going to explain you example of PHP select time from timestamp example. You will learn PHP select time from timestamp code example. get only the date in timestamp in PHP.
This article will give you simple example of convert timestamp to date in PHP query. We will use get search how to find the time from timestamo for a given date in PHP.
I will give you simple query to get timestemp from table.
Table: users
So, let's see bellow solution:
index.php<?php $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "db_php"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); $sql = "SELECT id, name, email, TIME(created_at) as time FROM `users`"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { echo '<pre>'; print_r($row); } ?>Output:
Array ( [id] => 1 [name] => Divyesh Barad [email] => divyeshbarad@gmail.coim [time] => 13:23:20 ) Array ( [id] => 2 [name] => Aatman Infotech [email] => aatmaninfotech@gmail.com [time] => 10:27:34 ) Array ( [id] => 3 [name] => Haresh [email] => savani@gmail.com [time] => 01:25:28 )It will help you...