Current location: Hot Scripts Forums » Programming Languages » PHP » auction countdown timer like in ebay


auction countdown timer like in ebay

Reply
  #1 (permalink)  
Old 05-11-05, 12:57 PM
edwient edwient is offline
New Member
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question auction countdown timer like in ebay

anyone here pls help me, how to create a countdown timer like in ebay, i'm using PHP and MySQL

i've try by SQL query ex:
id int, dt datetime

SELECT (now() - dt) FROM tanggal WHERE id ='1'

i thought it ll ve a result x Days y Hours z Minutes q Seconds

but i think it will work if i combine with the PHP script.
any solutions / codes / scripts / tutorials?

thanks you guys..
Reply With Quote
  #2 (permalink)  
Old 05-11-05, 02:55 PM
captainkoala captainkoala is offline
Newbie Coder
 
Join Date: May 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
you can set a time() stamp field in a database, and use getdate() to parse it.

example
PHP Code:

<?php


//list fields and convert to seconds
$countdown['days']=(5) * 24 60 60;
$countdown['hours']=(3) * 60 60;
// etc, etc
$countsum=time() + $countdown['days'] + $countdown['hours']; //and so on
// the above would be the timestamp to enter into the table

##########

// 'dumbed down' query
$result=mysql_query("SELECT * FROM tanggal WHERE id='id';");

while (
$row=mysql_fetch_assoc($result))
    
$time=$row['timestamp'] - time(); //this field would be a PHP timestamp (time())

$count=getdate($time);

$x=getdate(); //todays information

$count['mday'] -= $x['mday'];
$count['hour'] -= $x['mday'];
$count['minutes'] -= $x['minutes'];

echo 
"$count[mday] Days $count[hour] Hours $count[minutes] Minutes"//etc

// untested, but should work
?>
I'm not at home, or I would test it, but it should work.

/edit; I just realised that this will not work for countdowns in the next month

Last edited by captainkoala; 05-11-05 at 03:55 PM.
Reply With Quote
  #3 (permalink)  
Old 05-12-05, 01:19 AM
kenetix kenetix is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
you could use the unix timestamp (time()) and set that as the expiry

so say, the time will expire 3 days from the day you add the product,
time() + 3*24*60*60

and when you retrieve the info from the database just compare the present time and the expiry time.

PHP Code:

if($expirytime $currenttime){

echo
"expired";
}
else{
$remainingtime $currenttime $expirytime;

$remainingtime will be the number of seconds before the product expires. Just convert it to hours and minutes.
__________________
http://KENETIX.NET - FREE MONEY MAKING TOOLS & RESOURCES
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
eBay / PayPal auction payment script needed Synthetic Job Offers & Assistance 3 03-06-06 11:40 AM
Looking for Web Designer for Ebay Auction epic1231 Job Offers & Assistance 5 03-28-05 06:13 AM
countdown timer misterman JavaScript 1 03-22-05 01:35 PM
Do you know of an Auction script like Ebay? cyberman Script Requests 2 07-17-04 09:09 PM
Day elapsed countdown. Jaeboy PHP 1 11-19-03 09:23 AM


All times are GMT -5. The time now is 06:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.