Answer the question
In order to leave comments, you need to log in
How to implement next week check in Zend Framework?
Good day!
Recently I started to get acquainted with the Zend Framework and faced such a problem. I don’t know how to make a poll, or rather, a restriction on it in terms of the frequency of voting.
A user has the right to vote for another user once a week, but you can't just set a limit of 7 days, because. he must again be eligible to vote at the beginning of the week, no matter when his last vote was.
Everything is done in CMS Social Engine.
Perhaps someone has already encountered such a problem and can direct me to let the true one, I will be very grateful!
Answer the question
In order to leave comments, you need to log in
Thanks a lot for the answers!
As a result, I decided to do this:
1. We execute a query to the database, we find out there if the last record of the user has a date older than the start date of the week.
// Получаем первый день текущей недели
$getFirstDay = date('Y-m-d 00:00:00', strtotime('this week', time()));
$timestampFromStorage = 123456789; // когда пользователь последний раз голосовал
$votedWeek = date('W', $timestampFromStorage); // номер недели, когда пользователь голосовал
$todayWeek = date('W'); // номер текущей недели
if ($votedWeek * date('Y', $timestampFromStorage) < $todayWeek * date('Y')) {
// можно голосовать повторно
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question