php datetime comparation

Solutions on MaxInterview for php datetime comparation by the best coders in the world

showing results for - "php datetime comparation"
Jacqueline
02 Jun 2020
1
2<?php
3$date1 new DateTime("now");
4$date2 new DateTime("tomorrow");
5
6var_dump($date1 == $date2);
7var_dump($date1 $date2);
8var_dump($date1 $date2);
9?>
10
11
Mirko
05 May 2020
1dev:~# php
2<?php
3date_default_timezone_set('Europe/London');
4
5$d1 = new DateTime('2008-08-03 14:52:10');
6$d2 = new DateTime('2008-01-03 11:11:10');
7var_dump($d1 == $d2);
8var_dump($d1 > $d2);
9var_dump($d1 < $d2);
10?>
11bool(false)
12bool(true)
13bool(false)
14dev:~# php -v
15PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03)
16Copyright (c) 1997-2008 The PHP Group
17Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
18dev:~#
Paula
26 Jan 2018
1
2<?php
3$datetime1 new DateTime('2009-10-11');
4$datetime2 new DateTime('2009-10-13');
5$interval $datetime1->diff($datetime2);
6echo $interval->format('%R%a días');
7?>
8
9