[php] Add 'x' number of hours to date

I like those built-in php date expressions like +1 hour, but for some reason, they fall out of my head all of the time. Besides, none of the IDEs I'm aware of suggest auto-completion facility for that kind of stuff. And, finally, although juggling with those strtotime and date functions is no rocket science, I have to google their usage each time I need them.

That's why I like the solution that eliminates (at least mitigates) those issues. Here's how adding x hours to a date can look like:

(new Future(
    new DateTimeFromISO8601String('2014-11-21T06:04:31.321987+00:00'),
    new NHours($x)
))
    ->value();

As a nice bonus, you don't have to worry about formatting the resulting value, it's already is ISO8601 format.

This example uses meringue library, you can check out more examples here.

Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to date

How do I format {{$timestamp}} as MM/DD/YYYY in Postman? iOS Swift - Get the Current Local Time and Date Timestamp Typescript Date Type? how to convert current date to YYYY-MM-DD format with angular 2 SQL Server date format yyyymmdd Date to milliseconds and back to date in Swift Check if date is a valid one change the date format in laravel view page Moment js get first and last day of current month How can I convert a date into an integer?

Examples related to datetime

Comparing two joda DateTime instances How to format DateTime in Flutter , How to get current time in flutter? How do I convert 2018-04-10T04:00:00.000Z string to DateTime? How to get current local date and time in Kotlin Converting unix time into date-time via excel Convert python datetime to timestamp in milliseconds SQL Server date format yyyymmdd Laravel Carbon subtract days from current date Check if date is a valid one Why is ZoneOffset.UTC != ZoneId.of("UTC")?

Examples related to dateadd

How to add days to the current date? How to select last one week data from today's date Add 'x' number of hours to date MySQL - DATE_ADD month interval Subtract minute from DateTime in SQL Server 2005 SQL Server 2005 Using DateAdd to add a day to a date

Examples related to hour

Add 'x' number of hours to date Java getHours(), getMinutes() and getSeconds() How do I get hour and minutes from NSDate? Extracting hours from a DateTime (SQL Server 2005)