Skip to content

Instantly share code, notes, and snippets.

@robhob
Last active May 2, 2019 02:27
Show Gist options
  • Select an option

  • Save robhob/9b8e0e3c114a31a80082af3f0fc49b5f to your computer and use it in GitHub Desktop.

Select an option

Save robhob/9b8e0e3c114a31a80082af3f0fc49b5f to your computer and use it in GitHub Desktop.

Revisions

  1. robhob revised this gist Dec 7, 2018. No changes.
  2. robhob revised this gist Dec 7, 2018. No changes.
  3. robhob created this gist Dec 7, 2018.
    15 changes: 15 additions & 0 deletions daytime_check.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function is_daytime() {
    $time_now = date("H:i a");
    $time_now = DateTime::createFromFormat('H:i a', $time_now);
    $morning = "7:00 am";
    $morning = DateTime::createFromFormat('H:i a', $morning);
    $evening = "8:00 pm";
    $evening = DateTime::createFromFormat('H:i a', $evening);
    if ($time_now >= $morning && date("h:i") <= $evening)
    {
    return 1;
    }
    else {
    return 0;
    }
    }