$today = date("F j, Y, g:i a"); // October 30, 2019, 10:42 pm
$today = date("D M j G:i:s T Y"); // Wed Oct 3022:42:18 UTC 2019
$today = date("Y-m-d H:i:s"); //2019-10-3022:42:18(MySQL DATETIME format)
Get the Current Date and Time in PHP
phpCopy<?php$Object = new DateTime();
$DateAndTime = $Object->format("d-m-Y h:i:s a");
echo"The current date and time are $DateAndTime.";
In this page (written and validated by A. Gawali) you learned about
. What's Next? If you are interested in completing PHP tutorial, we encourage you simply to start here: PHP Tutorial.
Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: firstname.lastname@example.org.