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 −

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

665 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements