Add MySQL date (month-day) that accounts for every year - php

I'm making a web app in PHP that calculates vacations and some are fixed, say for example, Christmas, so instead of adding dates like
2015-12-25
2016-12-25
2017-12-25
2018-12-25
Is there any way to add something like
*-12-25
That accounts for every 25th of December of ALL the years? I know PHP has this but since I'm getting the dates from a Vacation Dates table that is populated by the admin I can't figure out how to do this in PHP, else I'll have to default to add 10 years to each entered date

Related

PHP/MySQL time date variable calculations

I have 2 variables, one a date like 06/02/2018 and a day interval that changes. I need to add the two together, then find the difference from the current date.
I've read carbon can help with this but I'm stuck.
say the vending machine was last filled on 6/20/2018 and it needs to be refilled every 30 days. I need to find out how many days from today it needs to be serviced.
Please help

PHP MySQL Table w AJAX: Filling in data for the whole year (day by day, only showing 7 days at once)

I’m struggling on how to design this small application. It’s going to be a table info where the columns will be dates and only 7 dates will be shown at any given time (the current day, plus the next six days).
The user NEEDS to be able to scroll to the left (or right, I suppose) and see previous dates with information that has bee entered for specific dates (ie, user wants to see the # of Service Jobs for February 14th, 2015).
What I have so far:
In this case there are 6 rows of information. The user can go in and edit this information. All of this data needs to be posted to a database, and the dates need to account for the whole year (ie, 1/1 to 12/31) and this has to happen every year. I’ve worked with the x-editable plugin a bit and have had some success, but I’m having a difficult time understanding how to account for all the differernt days of the year (365) and how to incorporate that into a MySQL database.
Current'y the 6 dates you see at the top of the img are shown using Javascript. The little dotted lines below the row values are from the X-editable plugin, and when you update this info it is posted to a database with a timestamp.
So my question is: how in the world do I account for 365 days for the year? It's not like I want 365 columns, each representing one day of the year, that seems crazy. (and the same thing will have to happen for 2016, 2017, etc etc...ongoing data).
I'm not sure if I've been taking the right approach on this. Feel like I'm making it much more painful than it needs to be.
Any input on how to design such an application would be greatly appreciated.
From a high level; I would just use an indexed DATE column.
A quick example:
<?php
$date_start = date('Y-m-d'); // Today
$date_end = date('Y-m-d', strtotime($date_start . ' + 6 days'));
// Assuming you have a PDO DB handler setup at this point...
$stmt = $dbh->prepare('SELECT * FROM `table` WHERE `day` BETWEEN ? AND ? ORDER BY `day` ASC');
$stmt->execute(array($date_start, $date_end));
$res = $stmt->fetchAll();
var_dump($res);

PHP MYSQL event sheduler like Musicteacherhelper.com

I have search over php mysql recurring events but didnt find anything exactly like i want.
I want to develop event sheduler in php mysql in which user add reccuring events based on daily,weekly,montly,yearly patterns using html form which is stored in mysql using php.
Like for example
user will enter start date,end date, what time event will happen(like 4:30pm) and duration of the event(like 2 hrs so it will make 430pm to 630pm event) with repeating patterns.For example event will repeat after 3 days , on monday and wednesday every week or after every two weeks, every 10th day of month or every 10th day after two months, on specific date every year or without any repeating patterns just add event for any specific date .
This information will be taken from user using html form and will be stored in mysql database and than it needs to display user upcoming events(e.g consider today is 13th july 2013 if recurring event is sheduled for 15th july 2013 it will consider as upcoming events) or events in the past(e.g consider today is 13th july 2013 if event is sheduled for 10th july 2013 it will be consider as past event) using php in two different ways using html table and arshaw full calendar.
I need help how i store event information in mysql database and than pull it using php and display upcoming or past events in html table and also be to integrate it arshaw full calendar.
This sort of stuff is already working in musicteacherhelper.com which also used php and mysql for implementing so i need to know is there any open source code available to implement this functionality.
Any help in this regard will be highly appreciated.
Thanks
Talha
use industry standard RRULE to store the informaton and some metadata of event in some mysql table for search purpose (example : date range)
http://www.kanzaki.com/docs/ical/rrule.html
demo : http://jkbr.github.io/rrule/
there are js and php libraries available for the same.

scheduling php mysql db design

We are trying to design a program that will allow users to book tutors based on tutors' availability. So we want tutors to tell us when (what time, day, etc) they are available/not available, and when a user books a specific day and time, we only want to show that user the tutors that are available for that particular day and time.
For example, tutors could tell us they are available M-W from 9-5PM.
How could I design such a table?
I was thinking of doing the followin
non-availability:
(this allows tutors to tell me they are not available on a specific date ... say 4/15/2012 10PM)
date date
time_start datetime
time_end datetime
recurring_non-availability
(this allows tutors to tell me that they are not available every Monday from 9-5pm)
dayOfWeek enum
time_start
time_end
So basically, tutors can specify for each day of the week, the times they are not available. They can also specify specific dates they are not available. If a user wants a tutor for a specific date like 4/20 10AM, I will first query the non-availability table to make sure there are no conflicts for 4/20 10 AM, and then query the recurring_non_availability table to make sure they are no conflicts for Friday (4/20 is on a Friday) 10 AM. I am not sure if this design will give me the best picture of a tutor's availability.
Perhaps set up a table with all the days of the week tutors will be available and then have the times they are stored within like so?
Tutor monday tuesday wednesday thursday friday
bob 9-5 9-5 9-5 10-3 9-12

Smart way to create a date functionality?

Current MySQL table schema: "Date" column with yyyy-mm-dd values
Assuming you are building a web app to rent out XBox's. Would you:
Create a a few checkboxes with "Every Monday," "Every Tuesday," "etc..." (Implication: If it's every Monday, how would you insert dates of only Monday's into the DB? Perhaps only insert the Monday's for the next three months initially and auto-increment and keep the tables light?"
Use a multi-datepicker for users to select multiple dates (Implication: User experience drops since the user will need to select more dates as time progresses?)
Other options?
How would add "hours" in addition to dates?
Store the data separately:
Start date - the start of the range
End date - the end of the range
Days of the week - the days of the week during the range (store this as a JSON array)
Hours per day - the hours per day (store this as a JSON object, with either start/end time per day of the week)
Try taking a look at Google Calendar add event page. They organize the times very smartly. It should give you some ideas for it.

Categories