Ok here are some lines: <span id="countdown<?=$taa;?>"><? echo date("Y-m-d H:i:s", $item_details['end_time'])." GMT-03:00";?></span> Code (markup): Everything seems to be correct. It uses a small .js file to calculate the time remaining between "now" and data stored in "mySQL" table. So first get the date then get items date then add zone function. After this script counts time to 0 and then prints CLOSED. (Its an auction). It works when i view auctions item details page: Time Left 2 days 01h 47m 24s But on the main page, where its supposed to show the same thing for featured products, it shows: 1970-01-01 02:00:00 GMT-03:00 Paths are correct. So whats is wrong? I just cant figure it out.
That's the date that it outputs if the input timestamp is considered invalid. As a debugging measure, have it echo the value you $item_details['end_time'] and post here what it is.
Ok, thanks for the replys. <? echo $item_details['end_time'];?> Code (markup): RESULTS: Nov. 15, 2008 18:20:06 Code (markup): So to test other variables etc. i used a simple php script: <?php $today = time(); $event = $item_details['end_time']; $countdown = floor(($event - $today)/86400); echo "$countdown"; ?> Code (markup): RESULTS: 1 So the MySQL part seems to be working.
Your problem is that $item_details['end_time'] is not a timestamp. You need to convert it using strtotime before it can be used in the date function.
Im starting to think that is a bug in this .js file... <? echo date("Y-m-d H:i:s", strtotime($item_details['end_time']))." GMT-03:00";?> Code (markup): RESULTS: 1970-01-01 02:00:00 GMT-03:00 Code (markup): Maybe you know some ajax/java scripts where i could easily use $item_details['end_time'] as a target date? Just like in this simple PHP code above, only it should do live counting.
I think you have more than one counters on your home page or the page you try to have working as you are mentioning the countdown works on singular countdown page (detail page) the js might be for one countdown. I suggest to change the countdown script. Just finished an auction site and was having same problem with old coders job. Just changed the script and now is working like a charm. If you want i can paste the code and js here. Just let me know.
Would be awesome xenous. My js file is meant for multible countdowns, but yeah... If you give me your js theres prob. alot of coding needed to make it fit my system. Thank you in advantage.
Was a quick fix so i did not edit the js or actions but the working is as follows Code is below js is in attachment. <?php if($status == 'auc'){ $date = ($rs_pre['auc_endate']);} if($status == 'pre'){ $date = ($rs_pre['auc_startdate']);} $date = date('F j, Y H:i:s', strtotime($date)); if($prop_status == 'Closed'){ echo "Auction is over"; } else { <span id="property_<?=$rs_pre[auction_id]?>"></span> <script language="javascript" type="text/javascript"> countdown('property_<?=$rs_pre[auction_id]?>', "<?=$date?>", 3, 'Halloween'); </script> <?php } ?> PHP: