help with countdown clock

A place to discuss and receive support for the Web Auction application.

help with countdown clock

Postby rosekolodny » Thu Sep 24, 2009 2:15 pm

So - I've got this nifty javascript countdown clock that will display the time remaining until some event. It wants the end time (in this case, the auction end time) in this format:

TargetDate = "12/31/2020 5:00 AM";

I would like to be able to grab the {$product->display('closing_time')} and give it to the javascript so I can have a cute little clock ticking down on each of my auctions, but I will have to format it differently OR tell the javascript to accept the format I already have.

I'm not really sure where to start, so any pointers would be nice. Thanks,

Beth
rosekolodny
 
Posts: 7
Joined: Sat Feb 07, 2009 11:25 pm

Postby shannah » Fri Sep 25, 2009 12:25 pm

In PHP:
http://ca2.php.net/manual/en/function.date.php
Code: Select all
date('m/d/Y h:i A', strtotime($product->display('closing_time')));


In a smarty template:
http://www.smarty.net/manual/en/languag ... format.php
Code: Select all
{$product->display('closing_time')|date_format:"%m/%d/%Y %r"}
shannah
 
Posts: 2894
Joined: Wed Dec 31, 1969 5:00 pm

Postby rosekolodny » Sun Sep 27, 2009 12:13 pm

Thanks! It is the super awesome.

Here's the link to the javascript I used:

http://www.hashemian.com/tools/javascript-countdown.htm

I placed Hashemian's code in my view_product.html file, with this line

Code: Select all
TargetDate = "12/31/2020 5:00 AM";


changed to

Code: Select all
TargetDate="{$product->display('closing_time')|date_format:"%m/%d/%Y %r"}";



Of course, I have the countdown.js hosted on my own server to save him the bandwidth.
rosekolodny
 
Posts: 7
Joined: Sat Feb 07, 2009 11:25 pm

Re: help with countdown clock

Postby rosekolodny » Wed Feb 03, 2010 2:28 pm

ONE MORE THING - the local user's timezone was affecting the way the countdown was displayed, so if the auction was ending 3 hours from now, the displayed time would differ depending on the local time of the user, making it seem like the auction had more or less time to go.

To fix this, the first line of Hashemian's code now reads thusly:
Code: Select all
TargetDate="{$product->display('closing_time')|date_format:"%m/%d/%Y %r CST"}";


The CST at the end of the date tells the browser to always use US/Central time. For simplicity's sake, I have hidden the timezone widget (during the registration process) and changed the timezone field in my users table to always be US/Central, because all of the end and start times for this auction are CST.
rosekolodny
 
Posts: 7
Joined: Sat Feb 07, 2009 11:25 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved