php greater than certain time

Viewed 58228

I am trying to make a simple function to output 2 different lines of text depending on the time of the day. I want it to say after 4pm - Next day delivery will be processed the following day.

I have wrote this so far:

<?php

   $currentTime = time() + 3600;
   echo date('H:i',$currentTime);                 

?>   

However as the date function returns a string, I am unsure of how to use an IF statement to check whether the time is greater than 16:00.

9 Answers

you can also check the difference between two Dates:-

<?php
$date1 = new DateTime("now");
$date2 = new DateTime("tomorrow");

var_dump($date1 == $date2);    //bool(false)
var_dump($date1 < $date2);    //bool(true)
var_dump($date1 > $date2);    //bool(false)
?> 
Related