How to Find Yesterday's Date in PHP

PHP code is used on websites to both display information and to interact with backend technologies, such as databases. PHP can also be used to execute calculations, such as displaying "yesterday's date" for any given day. So, for example, if you put the "yesterday's date" code on your website, no matter what date it is, the code will always display the previous day's date.

Instructions

    • 1

      Open your Text Editor or other program that you use to write your PHP code and then open the file that you want to display yesterday's date in.

    • 2

      Type "$yesterday = date('d/m/y', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));" to set the variable "$yesterday" equal to yesterday's date.

    • 3

      Save the file. You can now use the "$yesterday" variable to display yesterday's date, by using the "echo" function (like "echo $yesterday;").

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured