date_parse() FunctionThe date_parse() function in PHP is used to parse a date string into an associative array. The array contains individual date and time components such as year, month, day, hour, minute, second, and error information.
The function accepts a single parameter: a date string.
// Parsing a date string into components
date_parse(string $date)
In this example, a date string is parsed and displayed as an associative array.
// PHP example demonstrating date_parse()
<?php
$date_string = "2025-07-18 14:30:00";
$parsed_date = date_parse($date_string);
print_r($parsed_date);
?>
The output is an associative array containing values such as:
This makes it easy to work with individual parts of a date.
The diagram below conceptually shows how a date string is broken into components.
// Date string → Parsed array structure
"2025-07-18 14:30:00"
├── year: 2025
├── month: 7
├── day: 18
├── hour: 14
├── minute: 30
└── second: 0
date_parse() when you need granular date accessYYYY-MM-DD format and extract components