ExpertRefresh

String / Datetime  

Related Pages

Basics
Comparing
Searching
Parse
Replacing
Formatting
Printf
Regexp
Datetime


0.0% 100%
 
 
0 pages 298 questions
1) Add 7 days to a datetime object. <?php $datetime1 = new DateTime("2018-10-20"); $datetime1->add(______________);




2) Get days interval. <?php $datetime1 = new DateTime("2018-10-20"); $datetime2 = new DateTime("2018-10-30");







Add days <?php $datetime1 = new DateTime("2018-10-20"); $days = 7; $datetime2 = $datetime1->add(new DateInterval("P{$days}D")); echo $datetime2->format("d-m-Y"); // 27-10-2018 Get interval <?php $datetime1 = new DateTime("2018-10-20"); $datetime2 = new DateTime("2018-10-30"); echo $days = $datetime2->diff($datetime1)->format('%R%a'); // -10


References