How to Insert Current Date Automatically on a Webpage

The "PHP Date()" function can be used to automatically insert the current date into a webpage. The date function uses single characters to format the output (see Resources below). You can use the date function to display the date numerically or as a text string depending on the characters used. You can also print the current time using this function. In order to use the date function on a web page, you must place it within a PHP script.

Instructions

    • 1

      Open the HTML document in a text editor such as Windows Notepad.

    • 2

      Locate the section of the document where you want to insert the date.

    • 3

      Type the line "<?php" to begin the PHP script.

    • 4

      Type the line "echo date ("m/d/Y")."<br ?>";" to insert the current date on the screen. This will format the date as 01/01/2000.

    • 5

      Type the line "?>" to end the PHP script.

    • 6

      Save the file with the PHP file extension.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured