- This topic is empty.
-
AuthorPosts
-
May 8, 2011 at 4:28 pm #32642The-MarshalMember
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.
May 8, 2011 at 5:49 pm #77158TheDocMemberWhat are you trying to countdown? Is the countdown specific to a user?
May 9, 2011 at 1:35 am #77141The-MarshalMemberYes,
I’ve a group of users and in the their CPanel i want them to know how many days they still have.May 9, 2011 at 12:07 pm #77059TheDocMemberThen 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.
May 9, 2011 at 12:20 pm #77061The-MarshalMemberthanx 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
http://greatworks.eu5.org/count2/
Thanx again TheDoc .
May 9, 2011 at 12:51 pm #77069TheDocMemberRight, 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).
May 30, 2011 at 12:11 am #75018The-MarshalMemberok i found this fancy script
Countdown
could you please make YEAR, MONTH, DAY onlyi 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
May 30, 2011 at 12:56 pm #74952ddliuMemberI 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/2012Read PHP manual to get more information on date: http://php.net/manual/en/function.date.php
2. Get datetime differenc
$diffSecs=$expiration-time();
...//continue with your countdown script...
May 30, 2011 at 10:15 pm #74946The-MarshalMemberthanx 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.
May 31, 2011 at 1:48 am #74940ddliuMemberSorry 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: https://gist.github.com/1000031
function getDateDiff($date)
{
$diff_info=array();
$timestamp=strtotime($date);
$timestamp_diff=$timestamp-time();
//test if $date is future
$diff_info=$timestamp_diff>0;
$timestamp_diff=abs($timestamp_diff);
//calculate total date difference
$date_diff=round($timestamp_diff/(24*3600));
//year
$diff_info=floor($date_diff/365);
$date_diff-=$diff_info*365;
//month
$diff_info=floor($date_diff/30.5);
$date_diff-=floor($diff_info*30.5);
//day
$diff_info=$date_diff;
return $diff_info;
}
and how to use it:
$diff=getDateDiff('8/12/2012');
if($diff)
{
echo "You have {$diff} year(s), {$diff} month(s), {$diff} day(s) left";
}
else
{
echo "Your account has expired";
}
May 31, 2011 at 10:26 am #74899The-MarshalMemberThank you ddliu your script is fantastic i use it and get the variables from database
and it’s work thanx again you are awesome..☺
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.