
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Extract the Day / Month / Year from a Timestamp in PHP MySQL?
To extract the Day/Month/Year from a timestamp, you need to use the date_parse() function. The syntax as follows −
print_r(date_parse(“anyTimeStampValue”));
The PHP code is as follows −
$yourTimeStampValue="2019-02-04 12:56:50"; print_r(date_parse($yourTimeStampValue));
The snapshot of PHP code is as follows −
The following is the output −
Array ( [year] => 2019 [month] => 2 [day] => 4 [hour] => 12 [minute] => 56 [second] => 50 [fraction] => 0 [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => )
The snapshot of the sample output −
- Related Articles
- Create date from day, month, year fields in MySQL?
- How can we extract the Year and Month from a date in MySQL?
- Extract the month and year in the following format: “mm-yyyy” (month year) along with all columns in MySQL?
- Finding day of week from date (day, month, year) in JavaScript
- Filter the records of current day, month and year in MySQL?
- Fetch month, day, year, etc. from ISODate in MongoDB?
- Format MySQL date and convert to year-month-day
- Combine three strings (day, month, year) and calculate next date PHP?
- MySQL extract year from date format?
- How to get a Date from year, month and day in Java?
- How to extract only the month and day from a datetime object in Python?
- Convert day of year to day of month in Java
- How to get day name from timestamp in MySQL?
- How to compare Year, Month and Day in a MySQL query and display matching records
- How to convert year, month, and day of the month into a complete date in R?

Advertisements