The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Countdown with php ?

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • #32642

    Can you please tell me a way to make a countdown with php

    and when i refresh the page don’t start from the beginning!!!

    it’s continue.


    What are you trying to countdown? Is the countdown specific to a user?


    I’ve a group of users and in the their CPanel i want them to know how many days they still have.


    Then it won’t really be a ‘countdown’, per se.

    I assume each user has a location in a database somewhere. In that table I would create a new column for ‘user_expiry’ and make a call to that.

    I’m not knowledgeable enough in programming to help you further, but that’s the direction I’d go.


    thanx TheDoc ,

    what i need a countdown in php like:

    chris = > user he take hosting from my server and the period 3 month,

    so when he open his cpanel he will see how many days he still have

    but the problem i have is when i refresh the page count from the beginning

    have a look to this page

    Thanx again TheDoc .


    Right, the script on that page isn’t connecting to a database, so it will have no idea when the expiration date actually is.

    The expiry date of the account will have to be stored somewhere (database).


    ok i found this fancy script

    could you please make YEAR, MONTH, DAY only

    i think here change the value

    $date = array();
    $date = $diffSecs % 60;
    $date = floor($diffSecs/60)%60;
    $date = floor($diffSecs/60/60)%24;
    $date = floor($diffSecs/60/60/24)%7;
    $date = floor($diffSecs/60/60/24/7);

    i tried month like this

    $date = floor($diffSecs/60/60/24/7)%30;

    but didn’t working

    I appreciate any help


    I agree with @TheDoc, at least you have to get user data from database(including when will the account expire).

    Assuming you have got it and put it into a PHP variable “$expiration” and the format is UNIX timestamp.

    So next you can use $expiration to calculate useful infomation:

    1. Get the expiration date:

    echo "Your account will be expired on ".date('m/d/Y',$expiration);

    The output will be something like:
    Your account will be expired on 06/01/2012

    Read PHP manual to get more information on date:

    2. Get datetime differenc

    ...//continue with your countdown script...


    thanx ddliu

    really i don’t want to use this script as opening for my website but to my clients

    to know how many days they still have .

    this script has config page so i take the info from my database

    $id = $row->id;
    $year = $row->year;
    $Month = $row->Month;
    $day = $row->day;
    $message = $row->message;

    $config = array(
    'targetDate' => array( // Target countdown date
    'day' => $day,
    'month' => $Month,
    'year' => $year,
    'hour' => 0,
    'minute' => 0,
    'second' => 0

    and display it in control page of my client as a countdown

    so i want this script to display year, month, day only

    i tried but i face some problems and i need this script as soon as possible.


    Sorry I don’t quite understand what is your problem.

    Can you get expiration information from database?

    Can you calculate how long(e.g. how many days) will it expire?

    Do you have problem displaying it in the web page?

    Anyway, I can show you a function might be helpful:

    function getDateDiff($date)

    //test if $date is future


    //calculate total date difference




    return $diff_info;

    and how to use it:

    echo "You have {$diff} year(s), {$diff} month(s), {$diff} day(s) left";
    echo "Your account has expired";

    Thank you ddliu your script is fantastic i use it and get the variables from database

    and it’s work thanx again you are awesome..☺

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘Back End’ is closed to new topics and replies.