How to format the date of a string in PHP

Home > Search > How-to

Following is an example of how to print the current date in PHP. In this example, the current year will be printed.

   echo date("Y");


If you are fetching data from SQL, use this syntax to format the date in PHP:

   echo $row['date_column']->format('m/d/Y');


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.