Solved

Timimg in php

Posted on 2003-11-19
5
266 Views
Last Modified: 2008-03-06
I want to write the script that allow user to playing the simple puzzle game but the amount of time. For example the game start at 10:30 and support to be finished 2 hours later i.e 12:30 after that time the score will not be calculate. Could anyone tell me how to implement such a thing. Thank you
P/s i already wrote the game i just need to do the calculating score system.
0
Comment
Question by:jany2222
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
spearman123 earned 25 total points
ID: 9784133
0
 
LVL 1

Expert Comment

by:spearman123
ID: 9784151
look through there.. figure out how to find time and :

startTime = ....;
endTime = startTime + 120;
do {
/* game code */
nowTime = ....;
} while (nowTime < endTime);
0
 
LVL 1

Assisted Solution

by:show_source
show_source earned 25 total points
ID: 9786461
Or use time() and sessions
<?php
session_start();

do{
$_SESSION["startSec"] = time();
/* game code */
}
if($_SESSION["startSec"] < (60*60*2) {
ok
}

Instead af sessions, you could set a cookie

And with some Javascript you could show the  time there's left to play
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now