Dawn greater than night

1

How do I identify which

01:00:00(AM) é maior que 23:00:00h

Is there any function in php where I define it?

UPDATE:

if('2015-02-20 23:00:00' < '2015-02-21 01:00:00'){ //TRUE }
    
asked by anonymous 20.02.2015 / 18:24

1 answer

4

01:00:00 is not greater than 23:00:00 .

However, to identify whether 21/02/2015 01:00:00 is greater than 20/02/2015 23:00:00 you can compare timestamp. For example:

// mktime(hora, minuto, segundo, mes, dia, ano)
$timestamp1 = mktime(1, 0, 0, 2, 21, 2015);
$timestamp2 = mktime(23, 0, 0, 2, 20, 2015);

if ($timestamp1 > $timestamp2) {
    echo date("d/m/Y H:i:s", $timestamp1) . ' é maior que ' . date("d/m/Y H:i:s", $timestamp2);
    // 21/02/2015 01:00:00 é maior que 20/02/2015 23:00:00
}

I used the mktime function just as an example. You can use any feature that returns the timestamp ( time , strtotime , ...).

    
20.02.2015 / 19:33