Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617998
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:12:14+00:00 2026-05-22T02:12:14+00:00

I have coded a simple PHP Countdown Timer using this code: list($date,$time)=explode( ,$compounddate); list($thour,$tminute,$tsecond)=explode(:,$time);

  • 0

I have coded a simple PHP Countdown Timer using this code:

list($date,$time)=explode(" ",$compounddate);
list($thour,$tminute,$tsecond)=explode(":",$time);
list($tyear,$tmonth,$tday)=explode(":",$date);
$date=str_replace(":","/",$date);
$target = mktime($thour,$tminute,$tsecond,$tmonth,$tday,$tyear) ;

$today = time () ;

$difference =($target-$today) ;

$days = floor(abs($difference/86400));

$hours = floor(abs($difference%86400/3600));

$minutes =floor(abs($difference%3600/60));

$seconds = floor(abs($difference%60));

$date = date("F d, Y ",strtotime($date));
$time = date("g:i:s A",strtotime($time));
$past_future="";
$boolpast_future=true;
if($difference<0) {
$past_future="<strong> Time since ".$date." at ".$time.": </strong>";
$boolpast_future=false;
}
else {
$past_future="<strong> Countdown to ".$date." at ".$time.": </strong>";
$boolpast_future=true;
}
}

($thour, $tminute, etc mean target hour, target minute…)
However, this code does not calculate the countdown time properly. How to fix this? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:12:14+00:00Added an answer on May 22, 2026 at 2:12 am
    date_default_timezone_set('Asia/Tokyo');
    
    $target = new DateTime('2011-06-01 05:00:00');
    $now = new DateTime;
    $diff = $target->diff($now);
    
    if ($target > $now) {
        echo $diff->format('%a days, %h hours, %i minutes to go');
    } else {
        echo $diff->format('%a days, %h hours, %i minutes too late');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple PHP code: $query = mysql_query(SELECT `title`, `url_title` FROM `fastsearch` WHERE
i have a site with a simple PHP-Navigation (using $_GET-Variables). HTML-code for navigation links
Hi We have some php code using the file_get_contents() function, and I understand this
I have some code I've written in PHP for consuming our simple webservice, which
There is probably is simple fix for this but I currently have code similar
I have a simple php structures. class Ingredient and class Ingredients, i have this
I have this code, and works perfectly, but i want to make a simple
I have a simple php question. in my php , I have this: $variable
I have this simple code that is working fine in every browser, but NOT
So I have this simple PHP loop that is generating html table data with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.