Tags
Asked 2 years ago
9 Jun 2021
Views 181
ruby-rails

ruby-rails posted

how to get date time greater than today in php ?

how to get date time greater than today in php ?
noob

noob
answered Apr 26 '23 00:00

To get a date time greater than today in PHP, you can use the DateTime class along with the add () method. Here's an example:

php
Copy code
// Create a DateTime object for today's date and time
$today = new DateTime();

// Add one day to today's date
$today->add(new DateInterval('P1D'));

// Get the new date time as a string in the desired format
$date = $today->format('Y-m-d H:i:s');
In the example above, we first create a new DateTime object for today's date and time. We then use the add () method to add one day to the date. Finally, we use the format() method to get the new date time as a string in the desired format (Y-m-d H :i:s in this case).

Note that you can change the interval passed to the add () method to add any number of days, hours, minutes, etc. to the date time.
Post Answer