Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:13:46+00:00 2026-06-07T10:13:46+00:00

I have a task to create a script using php to display open and

  • 0

I have a task to create a script using php to display open and closed during the correct times. So far I have the time working correcty and this would be fine if the business was open during this time for 7 days a week. However the scenerio for the project is the business is open mon-fri 7:00am – 5:30 pm then open saturdays 7:00am to 1:00pm and closed sundays. I thought I could use a date function w since is displays 0-6 and call if

if($date >= 0 && $date < 6)

but that didn’t work. Here is the code I have so far

<?php

date_default_timezone_set('America/Chicago');
$open = "700";
$close = "1730";
$time = date('Gi');
$day = date('w');

if ($time >= $open && $time <= $close) {
    echo "We are Open";
} else {
    echo "We are closed";
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:13:49+00:00Added an answer on June 7, 2026 at 10:13 am

    If you’re not using a database you can hardcode each day of the week in some easily parsable format:

    $schedule[0] = "700-1730";
    $schedule[1] = "700-1730";
    $schedule[2] = "700-1730";
    $schedule[3] = "700-1730";
    $schedule[4] = "700-1730";
    
    $schedule[5] = "700-1300";
    $schedule[6] = "0";
    
    $today = $schedule[date('w')];
    
    list($open, $close) = explode('-', $schedule);
    
    $now = (int) date('Gi');
    
    $state = 'Open';
    
    if ($today[0] == 0 || $now < (int) $today[0] || $now > (int) $today[1]) {
      $state = 'Closed';
    }
    

    Just wrote the code, didn’t test it yet.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Script Task, I have written a code to create a folder and create
I have a script task that executes a dynamically created SQL restore statement. This
I have a content type Task, where we create task for ourself or user
The task: I am trying to create a custom data type and have it
I have task involving reading SAS .xpt files using .NET. For that I'm using
I'm using dhtmlx Gantt Chart UI component which have task list and graphical chart.
I would like to have a workflow create a task, then email the assigned
I have been given a task to create a Python file that will take
In SSIS 2008 I have a Script Task that checks if a table exists
I have a small Java/Gradle project. I'm using the Application plugin to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.