How to Get the Current Date and Time in PHP ^7.4.0

So, for this tutorial, let us make our own PHP script to check the dates of two years from given date and time.Both date and time can be used with PHP to represent a range of dates and times. You can do anything from adding an offset to a timestamp to different values in between (day, month, year,).How To Get The Current Date And Time In PHP get this data There you have it. A quick tutorial for easily generating pseudo tables in PHP. However, I also hope it will be interesting for some and you can use this knowledge to create tables of your own for web

How to Get the Current Date and Time in PHP:
<?php
// Return current date from remote live server
$date = date('d-m-y h:i:s');
echo $date;
?>
How to Get the Current Date and Time in PHP

Annotate query results with Comments
If you have a good idea of what the results of the query should look like, but do not want to leave a comment on the results, you can use the date_default_timezone_set() function before the date() function call.

Example:

<?php
// Set the new timezone for your mind
date_default_timezone_set('Asia/Kolkata');
$date = date('d-m-y h:i:s');
echo $date;
?>

Related FAQ

Get Yesterday date in php

How to split a string into an array in PHP

How to get the current year using PHP

Leave a Comment