J
J
jazzman72019-10-17 20:46:44
WordPress
jazzman7, 2019-10-17 20:46:44

How to compare two dates with time and in what format?

Hello. I checked similar questions, read the manual at www.php.net/manual/ru/datetime.diff.php, anyway the question is relevant for me.
In general, to the point. There is a date in the datetime-local format, say 2019-12-02T15:15
I need to add 90 minutes to it and compare it with the time at the moment, whether it is more or less.
Perhaps in a very strange way, I converted the date to a similar form 15:15 12/02/2019

$hdr = strtr($q['date1'], array('T' => ' ')); // вырезаю T
date('H:i d.m.Y', strtotime($hdr.':00')); //подгоняю под формат функции date() и вывожу

is it possible to convert time() to the same form and compare ? or it is necessary to pervert further and turn datetime-local into something else?
In general, what is the best way to implement my task?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ruslan, 2018-08-02
@Jmarfin

Easy, categories are subcategories, using advanced custom fields you add name / description fields for categories and display them, when displaying a category, you get child categories and show

D
DevMan, 2019-10-17
@jazzman7

$time1 = new \DateTime('2019-12-02T15:15');
$time1->add(new \DateInterval('PT90M'));
echo $time1->format('Y-m-d H:i'), PHP_EOL;

$time2 = new \DateTime();
echo $time2->format('Y-m-d H:i');

var_dump($time1 > $time2);
https://ideone.com/T9vHrL

F
FanatPHP, 2019-10-17
@FanatPHP

Citizens, have a conscience already
site: toster.ru+php+compare+two+dates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question