Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php DateTime comparation


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

var_dump($date1 == $date2);
var_dump($date1 < $date2);
var_dump($date1 > $date2);
?>

Comment

php DateTime comparation

dev:~# php
<?php
date_default_timezone_set('Europe/London');

$d1 = new DateTime('2008-08-03 14:52:10');
$d2 = new DateTime('2008-01-03 11:11:10');
var_dump($d1 == $d2);
var_dump($d1 > $d2);
var_dump($d1 < $d2);
?>
bool(false)
bool(true)
bool(false)
dev:~# php -v
PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
dev:~#
Comment

php DateTime comparation


<?php
$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a días');
?>

Comment

PREVIOUS NEXT
Code Example
Php :: instal phpgd2 
Php :: symfony set content type 
Php :: php return function result to variable 
Php :: php rotate image 
Php :: php print to console 
Php :: model with migration laravel 
Php :: csv utf-8 excel into php 
Php :: mac brew install php redis 
Php :: type casting in php 
Php :: if session is empty laravel 
Php :: find over array object php find 
Php :: file could not be downloaded: Unable to find the wrap per "https" - did you forget to enable it when you configured PHP? failed to open stream: No such file or directory 
Php :: in_array php 
Php :: how to get index 2nd php 
Php :: php artisan route cache 
Php :: Only variables should be passed by reference in 
Php :: display image in php from folder 
Php :: loop foreach laravel with number 
Php :: md5 (PHP 4, PHP 5, PHP 7, PHP 8) md5 — Calculate the md5 hash of a string 
Php :: learndash edit profile link 
Php :: laravel wheredate 
Php :: Clear and delete the folder after the time specified in php 
Php :: french special characters php 
Php :: php throw exception get message 
Php :: difference between use and require in php 
Php :: session not working php 
Php :: query relationships laravel and select some columns 
Php :: php print datetime 
Php :: shortcode in wp 
Php :: how to disable opcache 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =