i am building a quiz system,
the fields on the table is:
id, title, description, status, created, ended
the logic goes this way:
a quiz last only one week, it will automatically ends on the last day of the week (i am thinking on Saturday 24:00), and the admin should input the quiz on any day of the week, if it is inputted on Wednesday say at 01:00 pm, then the system should count the remaining time frame (in this case it would be around 83 hours) and then adds it to current time() to be inserted to the “ended” field.
am i on the right track?? and if i am, how should i count the remaining time frame in PHP ?
thanks
You can get the time stamp using
strtotime();and use the argument ‘next saturday’, so you could calculate the time remaining by doing something like this:That will give you a timestamp in seconds which you can divide by 3600 to get the hours.