- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
Advertisements