Show End date in (Ends: 9 Hours, 58 Mins +) Format
Moderator: General Moderators
Show End date in (Ends: 9 Hours, 58 Mins +) Format
Hi, can anybody tell me that how to get date this format (Ends: 9 Hours, 58 Mins +).
You can also view this from http://www.mobilityauction.com site
You can also view this from http://www.mobilityauction.com site
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I won't do it for you (for free anyway), but I, along with others here, will certainly help you.
The first thing you are going to need to know is what time it is now. Then you are going to need to know what time the listing ends. Then you are going to need to get the two date/times in a format that will allow you to subtract the later from the earlier. Then you will need to take that value, and convert it into the parts of time you want (Hours, Minutes and Seconds). Then echo those out.
Start with that and see what you can come up with. If you have problems, post your code and the community will help you sort it out. But try first.
The first thing you are going to need to know is what time it is now. Then you are going to need to know what time the listing ends. Then you are going to need to get the two date/times in a format that will allow you to subtract the later from the earlier. Then you will need to take that value, and convert it into the parts of time you want (Hours, Minutes and Seconds). Then echo those out.
Start with that and see what you can come up with. If you have problems, post your code and the community will help you sort it out. But try first.
- aerodromoi
- Forum Contributor
- Posts: 230
- Joined: Sun May 07, 2006 5:21 am
Here's a basic example for a countdown.
Shouldn't be too hard to do the math to split the output into days, hrs and minutes...
aerodromoi
Shouldn't be too hard to do the math to split the output into days, hrs and minutes...
Code: Select all
<?php
function countdown($dbdate){
$dbtime = strtotime($dbdate);
$ctime = date("U");
$tdiff = $dbtime - $ctime;
if($tdiff>0){
$difference = $tdiff." secs remaining.";
}
else{
$difference = "Sorry, time's up!";
}
return $difference;
}
$dbdate = "June 29, 2006 19:07:13";
print (countdown($dbdate));
?>Here is the code :
now i want to display an item w.r.t current time. if current time is less than the expiry time stored in database current date then item will be shown and end date of that item will b displayed in follwing format :
e.g; 4 days, 8 hours, 45 Mins // output
Code: Select all
$currentdate = time(); // current time
$expirydate = time() + (5 * 24 * 60 * 60); //Add 5 days to the cuurent datee.g; 4 days, 8 hours, 45 Mins // output
- aerodromoi
- Forum Contributor
- Posts: 230
- Joined: Sun May 07, 2006 5:21 am
If you're using a timestamp as the expiry date, you won't need strtotime in my function.eshban wrote:Here is the code :
now i want to display an item w.r.t current time. if current time is less than the expiry time stored in database current date then item will be shown and end date of that item will b displayed in follwing format :Code: Select all
$currentdate = time(); // current time $expirydate = time() + (5 * 24 * 60 * 60); //Add 5 days to the cuurent date
e.g; 4 days, 8 hours, 45 Mins // output
Just as a hint: You might want to take a look at floor for splitting the remaining time...
aerodromoi