Xtremer360 Posted May 6, 2011 Share Posted May 6, 2011 So inside my custom CMS i'm developing I have a module that controls various things like adding/editing awards, adding/editing award shows, and viewing voteCounts for the awardshows and for the individual nominees. Now the question I have is if there is a way without having to have the user make input to close the voting to have it actually close it by itself. Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/ Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 Use timestamps! If you want the vote to close in 30 days, simply have a close date stored in an sql database, or as a unix timestamp in a flat file. Before someone can vote, check the current date, if it's AFTER the close date, don't allow it! Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211681 Share on other sites More sharing options...
Xtremer360 Posted May 6, 2011 Author Share Posted May 6, 2011 Okay is it possible to have something like $year = date('Y'); then do on the insert statement : $Y-12-31 Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211699 Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 I'm assuming you mean $year-12-31 And yes, you can. Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211702 Share on other sites More sharing options...
Xtremer360 Posted May 6, 2011 Author Share Posted May 6, 2011 Unless there's a date function I'm unaware of that will find the last day of the current year. Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211703 Share on other sites More sharing options...
Xtremer360 Posted May 6, 2011 Author Share Posted May 6, 2011 Well I tried this and no matter what it puts the value into that dateExpires as 0000-00-00 $year = date('Y'); $query = "INSERT INTO `awardsShows` (awardsDate, statusID, creatorID, dateCreated, dateExpires) VALUES ('".$date."','".$statusID."','".$userID."', NOW(), '".$year."'-12-31)"; mysqli_query($dbc, $query); $result = "good"; Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211707 Share on other sites More sharing options...
incubi1 Posted May 6, 2011 Share Posted May 6, 2011 Try putting your date together before the query. $year = date('Y'); $year .= "-12-31"; $query = "INSERT INTO `awardsShows` (awardsDate, statusID, creatorID, dateCreated, dateExpires) VALUES ('".$date."','".$statusID."','".$userID."', NOW(), '".$year."')"; mysqli_query($dbc, $query); $result = "good"; Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211715 Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 '".$year."'-12-31 should have been '".$year."-12-31' And I'm assuming that 12-31 will ALWAYS be the last day of any given year Quote Link to comment https://forums.phpfreaks.com/topic/235734-awards/#findComment-1211735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.