The date() function in PHP formats dates and times into readable strings using format characters. It can work with the current system time or with a custom Unix timestamp.
// date() formats a timestamp into a readable date string
date(format, timestamp);
// Displays current date and time
The current system date and time are formatted as Year-Month-Day Hour:Minute:Second.
// Formats a custom timestamp
The timestamp represents Christmas Day 2025 at noon and is formatted accordingly.
Click the button to see today’s date using JavaScript formatting.
// Shows today's date dynamically
document.getElementById("showDate").onclick = () => {
document.getElementById("liveDate").textContent = new Date().toDateString();
};
date_default_timezone_set()strtotime() for flexibilityd-m-Yl