Fincikas Posted August 6, 2011 Share Posted August 6, 2011 Hi, Im begginer in all php and i have few questions for experts 1. I wanna set one time for all website or server. So if people will change the time on theyr own computers time in website will not change. 2. How to do something like this, if someone press the link, in database or somewhere should start to count the time. After that time counts down, something should automaticly inserts into database. Exaple: I press link to upgrade level. Level takes 5mins to upgrade. After 5min my level should become 2 from 1. And that should change that level 1from database and add level to2. So all im assking is, tell me much as you can about time and databases Thank you all for answers Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/ Share on other sites More sharing options...
MasterACE14 Posted August 6, 2011 Share Posted August 6, 2011 1. I wanna set one time for all website or server. So if people will change the time on theyr own computers time in website will not change. The time/date is independent of the server. echo date('l jS \of F Y h:i:s A'); // Prints something like: Monday 8th of August 2005 03:12:46 PM (FROM PHP.NET) Unless you're using Javascript which is clientside and will display the local time of the user. 2. How to do something like this, if someone press the link, in database or somewhere should start to count the time. After that time counts down, something should automaticly inserts into database. Use a timestamp. Create a 'timestamp' field in your database table. When the link is clicked insert the CURRENT timestamp and make the upgrade level link when pressed, check if the timestamp is 5mins old or not. Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253153 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 Ok thank you,i dont understood exactly, but now i know how to find what i need thank you very much This topic is solved now for me Thank you again Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253157 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 So, I surfed in google and in youtube, and all I get about timestamp was from what data it is counting and some other unuseful info. So maby you can explain this more like step by step? or maby create all code. Because I can understood code, more than idea Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253185 Share on other sites More sharing options...
voip03 Posted August 6, 2011 Share Posted August 6, 2011 <html> <head> <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTime()',500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } </script> </head> Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253186 Share on other sites More sharing options...
voip03 Posted August 6, 2011 Share Posted August 6, 2011 extra link 4u 2 learn. http://www.phpfreaks.com/forums/index.php?action=post;topic=340736.0;last_msg=1606572 http://www.w3schools.com/php/php_ref_date.asp Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253187 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 1st link dont work. Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253188 Share on other sites More sharing options...
voip03 Posted August 6, 2011 Share Posted August 6, 2011 http://www.plus2net.com/php_tutorial/php_date_time.php Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253199 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 I got new question, how to do that lets say in one hour in mysql numbers should increases 100. Example: i should get 100resources per hour. So 50resources per 30mins, 1.6resources per 1min and etc. And it should do it all automaticly, all the time. Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253248 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 <html> <head> <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTime()',500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } </script> </head> I red all pages you give me, but i still cant understand how to use this code in my website.... I know php but i never did anything with javascript, maby here is the point? Can you explain me more about all this? Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253267 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 So anyone can help me? Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253319 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 . Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253350 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 6, 2011 Share Posted August 6, 2011 create a cron job to run a php script every hour Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253356 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 create a cron job to run a php script every hour Dont understood what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253362 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 6, 2011 Share Posted August 6, 2011 create a cron job on your server which runs a php code every minute if you want. in that php script, the code updates the php script. Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253364 Share on other sites More sharing options...
Fincikas Posted August 6, 2011 Author Share Posted August 6, 2011 Are there any tutorials in these forums how to do it? Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1253368 Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 Cron Quote Link to comment https://forums.phpfreaks.com/topic/244023-few-questions/#findComment-1259228 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.