Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php compare two dates

$today = date("Y-m-d");
$expire = $row->expireDate; //from database

$today_time = strtotime($today);
$expire_time = strtotime($expire);

if ($expire_time < $today_time) { /* do Something */ }
Comment

php compare dates

$date_now = date("Y-m-d h:i:s");
$variable = new DateTime($date_now);
$to_compare = "2018-06-01 12:48:09";
$variable1 = new DateTime($to_compare);
$difference = date_diff($variable, $variable1)->format("Difference => %Y years, %m months, %d days, %h hours, and %i minutes");
echo $difference;
Comment

compare php date with mysql date

$today = date("Y-m-d");

$sql_query = "SELECT * FROM orders WHERE expireDate <=".strtotime($today);
Comment

compare dates datetime php

$date1 = new DateTime("now");
$date2 = new DateTime("tomorrow");

var_dump($date1 == $date2); // false
var_dump($date1 < $date2); // true
var_dump($date1 > $date2); // false
Comment

php compare dates

$date1 = "2021-01-15";
$date2 = "2021-01-18";

if ($date1 < $date2) {
 	echo "$date1 is earlier than $date2";
} else {
	echo "$date1 is later than $date2";
}
Comment

date comparison function in php

Select if(Date('2020-10-01') > Date('2020-11-01'), '1', '2' ) as rslt_date
Comment

PREVIOUS NEXT
Code Example
Php :: php 7 starts with 
Php :: remove empty array elements php 
Php :: laravel spatie asigne role 
Php :: install php 5.6 mac 
Php :: php usort method of class 
Php :: php read sql 
Php :: blade if array key exists 
Php :: laravel raw query join many to many 
Php :: layout.blade.php in laravel 
Php :: get relationship data from soft delete laravel 
Php :: js unserialize 
Php :: laravel has one 
Php :: laravel hasmany 
Php :: insert data using model in laravel 8 
Php :: update session laravel 
Php :: laravel global scope 
Php :: codeigniter 4 query builder get inserted id 
Php :: php extract month and year from date 
Php :: php foreach alternative syntax 
Php :: php migrate comand 
Php :: change the date format in laravel view page 
Php :: get term id by post id 
Php :: php error stack overflow 
Php :: json_decode 
Php :: get post info in php 
Php :: upgrade php7 to php 8 xampp 
Php :: display image in php from folder 
Php :: wordpress shortcode 
Php :: Laravel Eloquent Query Using WHERE with OR AND OR? 
Php :: array_filter first element php 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =