![]() |
Given a Date, the task is to extract day, month, and year from the date using PHP. There are various methods to extract day, month, and year, these are: Table of Content Approach 1: Using date() FunctionThe date() function in PHP allows you to format a date string. You can use it to extract the day, month, and year components. PHP
Output
Day: 01, Month: 01, Year: 2024 Approach 2: Using DateTime ClassThe DateTime class provides an object-oriented way to work with dates and times in PHP. You can use it to extract the day, month, and year components. PHP
Output
Day: 01, Month: 01, Year: 2024 Approach 3: Using getdate() FunctionThe getdate() function returns an associative array containing information about a given timestamp. You can use it to extract the day, month, and year components. PHP
Output
Day: 1, Month: 1, Year: 2024 |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |