Hello.
I'm considering building an auction feature in to my site, however I'm unable to figure out how to get started.
At present, reading from a database, I have selected the start date and time, then selected the duration in days.
And then, I'd like to work out days, hours, minutes an maybe seconds remaining or just time remaining.
I've tried dateDiff, but got a blank page.
May I ask if there is an easy way of achieving my goal?
At present I've written, which hopefuly calculated end date/Time:-
If the above works, how how can I show time remaining in real time?
Thanks.
I'm considering building an auction feature in to my site, however I'm unable to figure out how to get started.
At present, reading from a database, I have selected the start date and time, then selected the duration in days.
Code:
$start_time = openssl_decrypt($row_auction['start_time'], $ciphering, $decryption_key, $options, $decryption_iv);
$duration = $row_auction['listing_days'];
$ending = date('Y-m-d H:i:s', strtotime($start_time. ' + $duration days'));
And then, I'd like to work out days, hours, minutes an maybe seconds remaining or just time remaining.
I've tried dateDiff, but got a blank page.
May I ask if there is an easy way of achieving my goal?
At present I've written, which hopefuly calculated end date/Time:-
Code:
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$results = $conn->query('SELECT * FROM item_bid');
while ($row = $results->fetch()) {
$bidder_id = openssl_decrypt($row['bidder_id'], $ciphering, $decryption_key, $options, $decryption_iv);
$auction_id = openssl_decrypt($row['auction_id'], $ciphering, $decryption_key, $options, $decryption_iv);
echo $bidder_id . " - " . $auction_id . "<br>";
try {
$conn_auction = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn_auction->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$results_auction = $conn_auction->query('SELECT * FROM auctions');
while ($row_auction = $results_auction->fetch()) {
if ($row_auction['auctions_id'] == $auction_id) {
$item_auctionid[$mybidding_max] = $row_auction['auctions_id'];
$item_title[$mybidding_max] = openssl_decrypt($row_auction['title'], $ciphering, $decryption_key, $options, $decryption_iv);
$item_current_bid[$mybidding_max] = $row_auction['current_bid'];
$start_time = openssl_decrypt($row_auction['start_time'], $ciphering, $decryption_key, $options, $decryption_iv);
$duration = $row_auction['listing_days'];
//echo date('Y-m-d', strtotime($Date. ' + 10 days'));
$ending = date('Y-m-d H:i:s', strtotime($start_time. ' + $duration days'));
$item_time_left[$mybidding_max] = $ending;
$item_status[$mybidding_max] = openssl_decrypt($row_auction['status'], $ciphering, $decryption_key, $options, $decryption_iv);
echo $item_auctionid[$mybidding_max] . " " . $item_title[$mybidding_max] . " " . $item_current_bid[$mybidding_max] . " " . $item_status[$mybidding_max] . "<br>";
$mybidding_max++;
}
}
}catch(PDOException $e) {echo "A:-".$e;}
$_SESSION['mybidding'] = $mybidding_max;
}
}catch(PDOException $e) {echo "B:-".$e;}
?>
If the above works, how how can I show time remaining in real time?
Thanks.