DateTime::diff()
//get Date diff as intervals
$d1 = new DateTime("2018-01-10 00:00:00");
$d2 = new DateTime("2019-05-18 01:23:45");
$interval = $d1->diff($d2);
$diffInSeconds = $interval->s; //45
$diffInMinutes = $interval->i; //23
$diffInHours = $interval->h; //8
$diffInDays = $interval->d; //21
$diffInMonths = $interval->m; //4
$diffInYears = $interval->y; //1
//or get Date difference as total difference
$d1 = strtotime("2018-01-10 00:00:00");
$d2 = strtotime("2019-05-18 01:23:45");
$totalSecondsDiff = abs($d1-$d2); //42600225
$totalMinutesDiff = $totalSecondsDiff/60; //710003.75
$totalHoursDiff = $totalSecondsDiff/60/60;//11833.39
$totalDaysDiff = $totalSecondsDiff/60/60/24; //493.05
$totalMonthsDiff = $totalSecondsDiff/60/60/24/30; //16.43
$totalYearsDiff = $totalSecondsDiff/60/60/24/365; //1.35
Also in PHP:
- char to uppercase php
- error log display
- Main features of php
- Max character count for string in php
- date in php in dats
- codeigniter return id of last added record
- Allowed memory size of 134217728 bytes exhausted setup di compile
- To add a new Top-level menu to WordPress Administration, use the add_menu_page() function.
- "Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52"
- check if a word contains python
- date_default_timezone_set("America/New_York"); echo "The time is " . date("h:i:sa");
- all letters capital php
- decode ioncube php files
- contains php string
- Error: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
- create guid in php
- array merge in php
- case php try catch
- check strpos in php
- create a new laravel folder
- acf post object
- Laravel 7 do not see my new added seeder
- create a button add in laravel
- In Connection.php line 664:SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema