How to Get Current Date and Time in PHP?

In this post we will show you php today’s date, hear for php get month from date we will give you demo and example for implement.

Throughout, In this tutorial you’ll learn php datetime.This article goes in detailed on implementing php strtotime.If you want to learn php string to date. So, from this post, you can find step by step process of doing php date to timestamp.

How to Get Current Date and Time in PHP?

There are the Following The simple About php current date Full Information With Example and source code.

As I will cover this Post with live Working example to develop php date now

Using date() Function

 date(format, [timestamp])

<?php
    $currentDateTime = date('Y-m-d H:i:s');
    echo $currentDateTime;
?>

2022-02-27 08:22:26

date('Y/m/d');           //  2022/02/27
  date('m/d/Y');           //  02/27/2022
  date('H:i:s');           //  08:22:26
  date('Y-m-d H:i:s');     //  2022-02-27 08:22:26

Using DateTime() Class:

php DateTime() class functions

<?php
    $dt = new DateTime();
    echo $dt->format('Y-m-d H:i:s');
?>

Result:-

2022-02-27 08:22:26

Web Programming Tutorials Example with Demo

I hope you get an idea about php get current date.
I would like to have feedback on my pakainfo.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.