Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to Add Hours to Date and Time in PHP

by
Category:php
php
How to Add Hours to Date and Time in PHP

The following is really easy way to add hours in current date and time using PHP. Using the date function to set the format of the date to be returned then using strtotime. You may also like How to add One Hour in Current Date and Time using PHP and How to add one day in current date using php.

The following source code will add 2 hours to current date and time.

<?php
    $start = date('Y-m-d H:i:s');
    echo date('Y-m-d H:i:s',strtotime('+2 hour',strtotime($start)));
?>

The following source code will add 2 hours to date and time.

<?php
    $start = '2018-05-21 20:24:45';
    echo date('Y-m-d H:i:s',strtotime('+2 hour',strtotime($start)));
?>

And if you like this tutorials please share it with your friends via Email or Social Media.


0 Comments


Html code work in comment box


Related Post