How to Get Current Date and Time in PHP?

Question: how to get todays date in php?, how to get today’s date in php?, get today’s date in php,How to Get Current Date and Time in PHP?

Answer: Use the DateTime() Class: & PHP date() Function with Examples

Get Current Date and Time in PHP

You can use PHP date() function or DateTime() class to get current Date & Time in PHP. This Article, will help you to get current date time in PHP.

The provided outputs based on the timezone settings in the PHP main Config php.ini file. You may should to update this custom setting to get date and time in the need a current country relavnts timezone. Read this Article to set timezone in settings of the PHP configuration.

Also Read This πŸ‘‰   Difference between two dates in years, months, days in PHP
get today's date in php, php get current date and time, get todays date in php, php get current date time, how to get today's date in php,
php get current date and time

Using date() Function

PHP date() function converts the timestamp stored in computer memory in a human-readable format.

PHP Date Syntax & Example

PHP syntax

The syntax of PHP date() function is as:

 date(format, [timestamp])

The below php Example will return current get today’s datetime in β€˜Y-m-d H:i:s’ Popular format.

    $getTodaysDate = date('Y-m-d H:i:s');
    echo $getTodaysDate;

Result:- get today’s date in php

2021-11-25 08:14:12

Other useful examples:

php today’s date dd-mm-yyyy

  date('Y/m/d');           //  2021/11/25
  date('m/d/Y');           //  11/25/2021
  date('H:i:s');           //  08:14:12
  date('Y-m-d H:i:s');     //  2021-11-25 08:14:12

Get Your Time Zone

php get current timezone date and time

echo "The timezone is " . date("h:i:sa");

how to get todays date in php, php get today date, get the current date in php, how get current date in php, get todays date php, php get current date for mysql,
common date format characters

Using DateTime() Class:

The simple DateTime() PHP class functions allow you to get today’s date in php. You can also use PHP functions to format the Current date with time in multiple different types.

PHP DateTime() Class Example

    $getTodaysDate = new DateTime();
    echo $getTodaysDate->format('Y-m-d H:i:s');


2021-11-25 08:14:12

Here are list of the popular common PHP date format characters as well as their Key and data values.

Also Read This πŸ‘‰   PHP script to retrieve raw HTTP data using php input ("php://input")

PHP Date function reference

The Datetime Screen shot below shows the common all the related PHP Time parameters, Day parameters, Month Parameters, Year Parameters used when working with the get current datetime in php function.

Free Live Chat for Any Issue

PHP Time parameters

php get current date and time as string, php get current date in yyyy-mm-dd format, php today's date yyyy-mm-dd, get todays date time php,
PHP Time parameters

PHP Day parameters

php today date only, get current date using php, get now date in php, php get current date with timezone, php get date 5 days ago,
Day parameters

PHP Month Parameters

php get current date only, php get current date timestamp, php today's date dd-mm-yyyy, php get current date in milliseconds, php get todays date, php 7 get current date, php 7 get current datetime, how get today date in php
Month Parameters

PHP Year Parameters

php datetime, datetime in php, php datetime format, php current datetime, current datetime in php, datetime php, datetime difference in php, datetime format in php, convert string to datetime php, get date from datetime in php
Year Parameters

You can get the More References in PHP :Website functions Like and

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

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