Search
 
SCRIPT & CODE EXAMPLE
 

PHP

date diff php

$datetime1 	= new DateTime('2020-10-11 16:52:52');
$datetime2 	= new DateTime('2020-10-13 16:52:52');
$interval 	= $datetime1->diff($datetime2);

echo $interval->format('%a days');

$interval = $datetime1->diff($datetime2);
$diffInSeconds = $interval->s; 
$diffInMinutes = $interval->i; 
$diffInHours   = $interval->h; 
$diffInDays    = $interval->d; 
$diffInMonths  = $interval->m; 
$diffInYears   = $interval->y; 
Comment

php date diff in days

$earlier = new DateTime("2010-07-06");
$later = new DateTime("2010-07-09");

$pos_diff = $earlier->diff($later)->format("%r%a"); //3
$neg_diff = $later->diff($earlier)->format("%r%a"); //-3
Comment

PREVIOUS NEXT
Code Example
Php :: laravel foreach iteration 
Php :: how to call a helper function in blade 
Php :: laravel force delete 
Php :: php string beginnt mit 
Php :: for in php 
Php :: debian php switch version 
Php :: laravel image validate 
Php :: how to make db seeder in laravel 
Php :: php date + 30 days 
Php :: how make factory and seeder in laravel 8 
Php :: current time input field in laravel form 
Php :: no privileges to create databases phpmyadmin 
Php :: allow json uploads in Wordpress 
Php :: unset by key name php 
Php :: convert all text in php to uppercase 
Php :: convert timestamp to date php 
Php :: send attachment in mail php 
Php :: warning illegal string offset 
Php :: cut long text laravel blade 
Php :: hello world php 
Php :: cloudinary laravel 
Php :: get first name user 
Php :: laravel observer check if field changed 
Php :: ajax post json data handle in php 
Php :: eloquent update row response 
Php :: select sum laravel 
Php :: php get date between two dates 
Php :: php check if post file is empty 
Php :: email configuration for gmail in laravel 
Php :: next year php string 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =