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.

LEARN MORE

Comments

Your email address will not be published.

PHP for Beginners

Would you like lifetime access to the hugely successful PHP for Beginners course? Click here to find out how.

FREE Code Snippets

FREE hints and tips delivered direct to you once per month.