Science, Tech, Math › Computer Science Today's Date Using PHP Display the Current Date on Your Website Share Flipboard Email Print Neustockimages/E+/Getty Images Computer Science PHP Programming Tutorials MySQL Commands Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. Learn about our Editorial Process Updated on August 20, 2017 Server-side PHP scripting gives web developers the ability to add features that change to their websites. They can use it to generate dynamic page content, collect form data, send and receive cookies and display the current date. This code only works on pages where PHP is enabled, which means the code displays a date on pages that end in .php. You can name your HTML page with a .php extension or other extensions set up on your server to run PHP. Example PHP Code for Today's Date Using PHP, you can display the current date on your website using a single line of PHP code. Here's How It Works Inside an HTML file, somewhere in the body of the HTML, the script starts by opening the PHP code with the symbol.Next, the code uses the print( ) function to send the date it is about to generate to the browser.The date function is then used to generate the current day's date.Finally, the PHP script is closed using the ?> symbols.The code returns to the body of the HTML file. About That Funny-Looking Date Format PHP uses formatting options to format date output. The lower case "L"—or l—represents the day of the week Sunday through Saturday. F calls for a textual representation of a month such as January. The day of the month is indicated by d, and Y is the representation for a year, such as 2017. Other formatting parameters can be seen at the PHP website. Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "Today's Date Using PHP." ThoughtCo, Aug. 26, 2020, thoughtco.com/todays-date-using-php-2693828. Bradley, Angela. (2020, August 26). Today's Date Using PHP. Retrieved from https://www.thoughtco.com/todays-date-using-php-2693828 Bradley, Angela. "Today's Date Using PHP." ThoughtCo. https://www.thoughtco.com/todays-date-using-php-2693828 (accessed June 7, 2023). copy citation