// Month is August, Date is 15, Year is 2008
$d_var=getdate(mktime(0,0,0,8,15,2008));
echo "Month name in Full = $d_var[month]<br>";
echo "Month in numeric = $d_var[mon]<br>";
echo "Day of the Week, numeric = $d_var[wday]<br>";
echo "Day of the Week, Full name = $d_var[weekday]<br>";
echo "Day of the month = $d_var[mday]<br>";
echo "Day of the year = $d_var[yday]<br>";
echo "Day of the year = $d_var[year]<br>";
From any date we can get other details like month name , weekday, month number, weekday number, day of the month etc. by using getdate() function in PHP. This function takes time stamp of the required date as input and returns an array of details for that date.
$d_var=getdate([timestamp]);
Here timestamp is he optional argument by which we have to give the timestamp of the required date. By default it takes the current date and time as time stamp. Getdate function returns an array with different elements listed here.
$tm=mktime(0,0,0,8,15,2008);
echo date("M",$tm);
The above code will print Aug as month name for the given date value. We can use different date formats inside the date function to get desired date part value as per requirement.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.