Skip to content
Advertisement

Tag: dateadd

Add ‘x’ number of hours to date

I currently have php returning the current date/time like so: What I’d like to do is have a new variable $new_time equal $now + $hours, where $hours is a number of hours ranging from 24 to 800. Any suggestions? Answer You may use something like the strtotime() function to add something to the current timestamp. $new_time = date(“Y-m-d H:i:s”, strtotime(‘+5

Advertisement