Solved

Timimg in php

Posted on 2003-11-19
5
267 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Keep getting 503 on Curl request 6 31
Apache/PHP: Cannot make phpinfo() and phpmyadmin work 4 35
Amazon Redshift 2 26
mcrypt_create_iv() is deprecated 4 74
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

920 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

15 Experts available now in Live!

Get 1:1 Help Now