PHP MySQL Get Day Name from Date Example
Feb 23, 2022 . Admin
Hello Friends,
I am going to explain you example of PHP get day name from date example. You will learn DAYNAME() Examples – PHP. I would like get day name from timestamp in PHP.
This article will give you simple example of DAYNAME() : Full Day name in PHP. Now, let's see article of how to get day name from date in PHP query.
I will give you simple query to getting data get day name from date 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 *, DAYNAME(created_at) as day_name 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 [created_at] => 2021-12-16 13:23:20.000000 [updated_at] => 2022-02-21 13:23:20.000000 [expired_at] => 2022-02-21 13:23:20.000000 [day_name] => Thursday ) Array ( [id] => 2 [name] => Aatman Infotech [email] => aatmaninfotech@gmail.com [created_at] => 2022-01-12 13:24:34.000000 [updated_at] => 2022-01-12 13:24:34.000000 [expired_at] => 2022-02-21 13:24:34.000000 [day_name] => Wednesday ) Array ( [id] => 3 [name] => Haresh [email] => savani@gmail.com [created_at] => 2022-02-21 13:25:28.000000 [updated_at] => 2022-02-21 13:25:28.000000 [expired_at] => 2022-02-21 13:25:28.000000 [day_name] => Monday )It will help you...