1

In my code I've a scenario like this :

<?php
     $start = "03:00:00:am";
     $end   = "08:00:00:pm";

      if($start > $end) {}   
?>

I tried with unix timestamp but it didnt worked.

Deepa
  • 184
  • 1
  • 2
  • 16
Riyad Mohammad
  • 31
  • 1
  • 1
  • 5

2 Answers2

5

Try this, I do not think that the am, pm at the end is the correct formatting but with dates you should be able to test them in this way:

$start = strtotime("03:00:00");
$end   = strtotime("20:00:00");

if($start > $end) {}
Schalk Keun
  • 538
  • 4
  • 13
1

Use this code:

<?php
$start = strtotime("03:00:00");
$end   = strtotime("20:00:00");

if($start > $end) {
 echo "Yes";
}
else{
    echo "No";
}
?>

More info: http://php.net/manual/en/function.strtotime.php

Chandra Kumar
  • 4,127
  • 1
  • 17
  • 25