Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: david Panter
Added: Apr 29, 2019 1:14 PM
Views: 3
Tags: no tags
  1. $current_time = "4:59 pm";
  2. $sunrise = "5:42 am";
  3. $sunset = "6:26 pm";
  4. $date1 = DateTime::createFromFormat('H:i a', $current_time);
  5. $date2 = DateTime::createFromFormat('H:i a', $sunrise);
  6. $date3 = DateTime::createFromFormat('H:i a', $sunset);
  7. if ($date1 > $date2 && $date1 < $date3)
  8. {
  9.    echo 'here';
  10. }