PHP MySQL Select Minutes from Timestamp Example

Feb 25, 2022 . Admin

Hello Friends,

I am going to explain you example of PHP select minutes from timestamp example. You will learn PHP - search timestamp by minutes of day. In side this article we will see the PHP - extract minutes from DATETIME / TIMESTAMP / TIME.

This article will give you simple example of how to display only minutes and minutes in PHP?. We will use get search how to find the PHP get date difference in minutes code example.

I will give you PHP date format and timestamp functions with examples.

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_FORMAT(created_at, '%H:%i:%s') as time,
            TIME_FORMAT(created_at, '%H') as hour,
            TIME_FORMAT(created_at, '%i') as minute,
            TIME_FORMAT(created_at, '%s') as minute
        FROM `users`";

$result = $conn->query($sql);

while ($row = $result->fetch_assoc()) {
    echo '<pre>';
    print_r($row);
}

?>
Output:
Array
(
    [id] => 1
    [name] => nikhil thumar
    [email] => nik123@gmail.com
    [time] => 09:28:17
    [hour] => 09
    [minute] => 17
)
Array
(
    [id] => 2
    [name] => hardik savani
    [email] => hardi123@gmail.com
    [time] => 16:28:09
    [hour] => 16
    [minute] => 09
)
Array
(
    [id] => 3
    [name] => aatman infotec
    [email] => aatmaninfotec@gmail.com
    [time] => 09:33:47
    [hour] => 09
    [minute] => 47
)
It will help you... example of PHP select minutes from timestamp example, PHP - search timestamp by minutes of day, the PHP - extract minutes from DATETIME / TIMESTAMP / TIME, simple example of how to display only minutes and minutes in PHP?, how to find the PHP get date difference in minutes code example, PHP date format and timestamp functions with examples.
#PHP