We need to store schedules for people in different time-zones, however the schedule repeats either weekly or in a particular day of the month. the problem is we can't store an exact date and can't store time-zone either due to some requirements. the initial solution that we came up with was use three columns :
day => which would specify the day of the recurring event such as "Monday" or "25",
start_time => which would specify the UTC time of the event starting,
end_time => which would specify the UTC time of the event ending.
databaseImageOfEntries
the problem is though if someone has a local time of +10-GMT for example, and they want to store a schedule for the first day of the month in their local time, then the conversion to UTC should give us the last day of the previous month at start_time of "14:00" UTC but some months are not 30 days, so we have no way of storing the correct day in the database since we can't determine what day it will be in each month.
I would really appreciate your suggestions.
Related
Trying to capture some information when a user inputs two dates. The information I'm getting back is correct apart from the dates are off by one. So if I ask for 13th 14th 15th I get the correct information back but the dates are 12th 13th 14th.
Found the issue it's to do with BST time being 1 hour ahead. Just not really sure how to rectify it apart from sticking my PC an hour behind.
Check the date stored in the database it might be stored in UTC Format. If it is in UTC Format, you must handle it in your code to match on your time zone.
I am creating an attendance system and i want to automatically change the subject based on the time of the day. I have a table consist of subject name, start time, end time and its day. I have a question, is it possible to automatically get the value of a row based on specific time and day?
For example the current time is 12:45 PM and the day is Tuesday. This is my sample table. Then the output will be Principles of OS.
in mysql to get the name the current day use
DAYNAME(date)
and compare it to your sub_day column in selection
This is related to an earlier question that I had here: Convert datetime to a fixed date of the month including the time - mysql
I am raising a another question because this is regarding the timezone component in the datetime.
I have a list of date time values that are stored in GMT. For the purpose of a report, I want to convert the dates to a single date of a month. (which was the subject of the previous thread I mentioned above). What I also would like to do is the take the time zone into consideration. I will explain.
The date field is always stored in GMT. But the report is generated for the HQ that is in EST. So when there the dates are converted to a single date time (again, part of the previous thread) only the dates that fall into that month in EST (not GMT) should be changed to that month.
For example, let us say I have this date stored in the table:
2016-04-01 00:03:07 (GMT). But for a person sitting in Eastern time zone this is created in the month of March. So, when I do the conversion of the dates to a specific date of a month, this date should be converted to 2016-03-15 00:00:00 and not 2016-04-15 00:00:00
Pretty challenging to me!
I need this in this format as I am integrating with a third party application
CONVERT_TZ should be able to convert to your required timezone. Then, do the rest of the operations on the result instead of doing them on th original date.
I'm building an 'events' table that will show the events for that particular day.
However, since most events start late in the evening and end early in the morning I would like to know as to how I should plot and retrieve the data. Let's say that and event day starts at 6:01 AM and ends at 6:00 AM. Is the time dependent on the server time? Can I change it to some other GMT time? How would the time table look in the mysql database?
Thank you!
I would have a table like this:
Event
======
EventID
Name
StartTime
EndTime
StartTime and EndTime would be stored as UTC dates. With this schema you can query however you like, and present the time for whatever time zone you like, but it keeps things consistent and well performing. You would want to index EventID, StartTime, and EndTime.
I want to grab records from a table based on the day of the month the record was created.
This information is stored in a Unix timestamp. During testing I created new test records and threw in some timestamps for specific times that I had converted to timestamps using an online converter. I used...
01/29/2010-02:00:00
Right now I'm using...
FROM_UNIXTIME(timestamp, '%d') == 29
This should work for all times on the 29th day of every month. But it is calculating the timestamp to be 5 hours behind the actual value of the timestamp. When I just run a FROM_UNIXTIME on the timestamp it returns 01/28/2010-21:00:00. I was hoping someone could give an explanation for this, if there is an easy fix or should I just code the program to expect the timezone to be a factor.
The FROM_UNIXTIME function automatically converts the datetime to the current timezone.