Jump to content

Few questions :)


Fincikas

Recommended Posts

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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?

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.