callesson Posted May 7, 2010 Share Posted May 7, 2010 Hey Guys! or Chicks! I wanna work with php and Time but im not good at it, so I wonder if there is someone out there who could help me ? Ty! Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/ Share on other sites More sharing options...
doddsey_65 Posted May 7, 2010 Share Posted May 7, 2010 there are alot of things people could help you with but your question is too open. How about explaining what you need help with specifically. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054563 Share on other sites More sharing options...
callesson Posted May 7, 2010 Author Share Posted May 7, 2010 Sure thing, I just wanted help to be confirmed first Maybe nobody wanna help me haha. But okey lets explain. First Thing: I have a submit button that will rederict you to another page. If that submit is set then your not gonna be able to use it again after like 10 or 30 min. So I would like to check that, and without problems with like if its another day or something. Also I would like to calculate the time thats left so I could display it. __ Sec Thing: I want something to update every hour. Like for each hour update something +10. I would like it to check like this. If you logout, and then you login after 2 h you will get 20 of something. And also if you are loged in it will update. But if there is another way, feel glad to tell __ Ty! Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054571 Share on other sites More sharing options...
trq Posted May 7, 2010 Share Posted May 7, 2010 And you are stuck where? Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054578 Share on other sites More sharing options...
doddsey_65 Posted May 7, 2010 Share Posted May 7, 2010 i think he wants someone to do it for him Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054584 Share on other sites More sharing options...
cs.punk Posted May 7, 2010 Share Posted May 7, 2010 Learn PHP! Or search for a script because thats what your asking for? Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054588 Share on other sites More sharing options...
callesson Posted May 7, 2010 Author Share Posted May 7, 2010 Sry for that. No dont want you to do it for me xD Well im stuck at the Calculating, and Checking so its the right day. Right now Im adding a time into the Database (Date() + 10 or 30 min) when the submit is set, then next time its set it will check if date() is > then Database time. And for the second thing, I just want an idea. Cause I have no idea how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054601 Share on other sites More sharing options...
siric Posted May 7, 2010 Share Posted May 7, 2010 Post your code so we can have a look at it. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054606 Share on other sites More sharing options...
theocas Posted May 7, 2010 Share Posted May 7, 2010 You could just use cookies to disable the submit button. When the form is loaded, check if the cookie has some kind of value, and if it does, disable it. If it doesn't then dont. When the form got submitted, set a cookie that lasts 30 minutes, or 60 * 30 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054608 Share on other sites More sharing options...
callesson Posted May 7, 2010 Author Share Posted May 7, 2010 Siric: I do not have my code right here, but its as simply as this ( Do not correct this code) <form ... method="post"> ... <input type="submit" name="submit"/> ... ... if(isset($_POST['submit'])) { $time = date() + 10 min; $up = mysql_query("UPDATE table SET time=$time where user=$_SESSION..."); } then next time: $select = mysql_query("SELECT * FROM table where user=$_SESSION..."); $time = $row[time]; $date = date(); if(isset($_POST['submit']) && $date < $time) { echo "You cant do this now... Time left x"; } theocas: Well, I could check on that. But i havent worked with cookies before. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054611 Share on other sites More sharing options...
Mchl Posted May 7, 2010 Share Posted May 7, 2010 And cookie can be modified/deleted by user, so that's not really a good solution. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054646 Share on other sites More sharing options...
teamatomic Posted May 7, 2010 Share Posted May 7, 2010 You should be using a timestamp,date("U"). Lots easier to check for a few minutes diff and you dont have to worry about what day it is. Then just use an if statement to display the submit button if it within your params. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054656 Share on other sites More sharing options...
gwolgamott Posted May 7, 2010 Share Posted May 7, 2010 This is already answered, but since I am Guy.. thought I had to add my two cents...haha <?php $server_local_time = time(); //gives UNIX time (the number of seconds since January 1 1970 00:00:00 GMT) echo(date("D F d Y",$server_local_time)); // will display something like: Wed April 14 2010 ?> reference code for date() so if you want to use hours obviously... instead of calendar date. Here is the list Required. Specifies how to return the result: * d - The day of the month (from 01 to 31) * D - A textual representation of a day (three letters) * j - The day of the month without leading zeros (1 to 31) * l (lowercase 'L') - A full textual representation of a day * N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday) * S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j) * w - A numeric representation of the day (0 for Sunday through 6 for Saturday) * z - The day of the year (from 0 through 365) * W - The ISO-8601 week number of year (weeks starting on Monday) * F - A full textual representation of a month (January through December) * m - A numeric representation of a month (from 01 to 12) * M - A short textual representation of a month (three letters) * n - A numeric representation of a month, without leading zeros (1 to 12) * t - The number of days in the given month * L - Whether it's a leap year (1 if it is a leap year, 0 otherwise) * o - The ISO-8601 year number * Y - A four digit representation of a year * y - A two digit representation of a year * a - Lowercase am or pm * A - Uppercase AM or PM * B - Swatch Internet time (000 to 999) * g - 12-hour format of an hour (1 to 12) * G - 24-hour format of an hour (0 to 23) * h - 12-hour format of an hour (01 to 12) * H - 24-hour format of an hour (00 to 23) * i - Minutes with leading zeros (00 to 59) * s - Seconds, with leading zeros (00 to 59) * e - The timezone identifier (Examples: UTC, Atlantic/Azores) * I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise) * O - Difference to Greenwich time (GMT) in hours (Example: +0100) * T - Timezone setting of the PHP machine (Examples: EST, MDT) * Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200) * c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00) * r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200) * U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1054717 Share on other sites More sharing options...
callesson Posted May 8, 2010 Author Share Posted May 8, 2010 Okey okey! Ty guys! Sry if I was unclear in the beggining but I was at work and I was tired But Thx! Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1055019 Share on other sites More sharing options...
TeddyKiller Posted May 8, 2010 Share Posted May 8, 2010 I believe for your first thing you could do this... (Might have some flaws but you should get the picture) <?php if(isset($_POST['submit'])) { $time = time() + 10000; //10 seconds, so change this to whatever.. $up = mysql_query("UPDATE table SET time=$time where user='".$_SESSION['blah']."'"); } echo '<form action="" method="post" >'; $query = mysql_query("SELECT * FROM table where user='".$_SESSION['blah']."'"); if(($row['time'] + 10000) < time()) { //Again.. 10 seconds so change it echo '<input type="submit" name="submit" value="submit" disabled />'; echo 'You cant do this now. Please wait... ' . date('i', $row['time'] - time()) . 'minutes'; } else { echo '<input type="submit" name="submit" value="submit" onclick="this.disabled = true" />'; } echo '</form>'; ?> For your sec thing .. if you have a last active collum in the database. which gets updated upon loading on the page by time(), then what you'd do.. if something like.. if(($row['last_active'] + 60000) < time()) { //20 something } 60000, is 60 seconds.. so that'll need to be changed corresponding to what you wish to do. A simple method is used for the login too. You'll need to get the details from the database based on the user trying to login. Quote Link to comment https://forums.phpfreaks.com/topic/201000-guy-how-knows-php-time-could-be-a-chick-too/#findComment-1055035 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.