Getting the Current Date in PHP

In this brief lesson we look at how we can obtain the current date in PHP.

There are several methods but the easiest is to just use the date() function with passed in parameters.

For example, we can use 'Y-m-d' to represent the Year, month and day:

<?php

echo 'Current Date: '. date('Y-m-d');

The output will be:

Current Date: 2018-01-10

If you would like to learn more about PHP then enrol in the PHP for Beginners course.

Want to Learn More?

Become a member and get access to the member only area of this site here.

Comments

Your email address will not be published.

PHP for Beginners

Enrol in the full course here

PHP, MySQL and PDO

Coming soon, a full course on using PHP, MySQL and PDO. Be notified as soon as the course goes live.