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.

1

2 Answers 2

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) {} 
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.