How to Make a Date in PHP

PHP is a programming language used to create dynamic webpages. Dynamic webpages allow individuals and businesses to supply users with content that displays according to user input. If a user clicks a product link, the product page shows the proper product information. One task for developers is to display the current date on the page. You can create a date variable and display it to the user in PHP using only one line of code.

Instructions

    • 1

      Right-click your PHP file on your web host or computer and select "Open With." Select "Notepad" from the list of program options. This opens the PHP code file in the Windows default text editor, which is sufficient for quick code edits.

    • 2

      Scroll down the file to where you want the date displayed. Enter the following code into the file:

      $date = getdate ( );

      This code retrieves the current date and sets it to a $date variable.

    • 3

      Print the date to the webpage, which allows the user to see it from the browser. Enter the following code in the next line:

      print_r($date);

    • 4

      Click the Notepad "File" menu item and select "Save." This saves the changes to your PHP code file.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured