Forum Moderators: coopster
Working through that would be a tutorial in itself and, of course, hundreds of typists wait here to help you out ;-)
Seriously, working your way through code is a great way to learn and if you get stuck, we'll help out here.
I didn't end up finding a script but i worked out the logic myswel. Turns out that it is really basic. But i do need help implementing the date/time functions in php/mysql.
Basically, this is the process a script goes through to add aproject.
1. Add project button clicked
2. store length of auction(int) and current time.
3. Display start date/time: now, end date: now+auction length, time left: end date-now
I can do all of the following except for find out how long the auction has left.
If a user adds a project now, sets length to 7 days then checks on it this time tommorow, i want to display the following: Time Remaining: days, hours, minutes.
I am have a hard time find the days, hours, minutes variables. I've messe around with UNIX_TIMESTAMPS ect but cant get it to work.
$get_stamp = "SELECT (UNIX_TIMESTAMP('$end') - UNIX_TIMESTAMP(now()))";
$s = mysql_query($get_stamp, $link) or die(mysql_error());
$sr = mysql_fetch_row($s);
$stamp = $sr[0];
$get_left = "SELECT $stamp, $stamp / 60, $stamp / (60 * 60), $stamp / (24*60*60), $stamp / (7*24*60*60)";
$a = mysql_query($get_left, $link) or die(mysql_error());
$sw = mysql_fetch_row($a);
$seconds = $sw[0];
$minutes = $sw[1];
$hours = $sw[2];
$days = $sw[3];
$weeks = $sw[4];
That code gives me large decimal numbers that are hard to work with. Is there an easier way to do it in php?
Thanks again :)
I worked it out :)
$get_stamp = "SELECT (UNIX_TIMESTAMP('$end') - UNIX_TIMESTAMP(now()))";
$s = mysql_query($get_stamp, $link) or die(mysql_error());
$sr = mysql_fetch_row($s);
$stamp = $sr[0];
$seconds = $stamp;
$days = floor(($seconds/86400));
$rem = $seconds % 86400;
$hours = floor(($rem/3600));
$rem = $rem % 3600;
$minutes = floor(($rem/60));
$seconds = $rem % 60;