Jump to content

Recommended Posts

Is there a way to put the value of every 15mins into an array starting and finishing at 2 var times

 

$time1=10.00am

$time2=1.30pm

 

$timearray=array($time1, and every 15min interval up to but not including $time2)

        eg  $timearray=array(10.00am,10.15am,10.30am..........1.15pm)

get the system time using PHP - there are built in functions, like date, I think.

 

Check if the time is between the times you want.

 

Log data.

 

To re-run the code, you might need a javascript timer set up that would refresh the page automatically every 15 minutes. But that's if you're using it in a website context.. and I'm not sure how you could be...

I am wanting to echo the value of time every 15 minutes between the value of $time1 and $time2 comes from the database.

Its for appointment bookings.

I have converted them to timestamps using the date of the appointment and I have been trying to create a loop to add 900(15mins) to $time1 until it reaches $time2 but not had much success yet.

 

Anyone have an idea how to run the loop to do this, the snag I having is $time1 and $time2 come from a while loop that pull the staff working times from a db on the booking date

I have worked it out, I changed the times in my database to be 24hr times not 12 hour with am/pm

the performed the following

$sqlDATE=user input date from calendar select formated to yyyy-mm-dd
$in="$sqlDATE 10.00:00"; // selected date + start time for staff member from database(24hr time)
$out="$sqlDATE 18.00:00"; // selected date + finish time for staff member from database(24hr time)
$in2=strtotime($in); // convert to timestamp
$out2=strtotime($out); //convert to timestamp
$stop=$out2-900; // 900 is 15 mins used to set last 15min appointment before staff finish
// get the 15min variables in this case I am just echoing them
for ($inc=$in2;$inc<=$stop;$inc=+900) {
    echo "Appointment time is ".date("g.i a", $inc)."<br/>"; // set back to readable time
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.