Convert unix time to readable time in housekeeping
Hello!
I need help, cause I fix things in housekeeping and in banlist I want the expiring time to be readable. Im using boon emulator and the expire structure in database is in DOUBLE unix time.
So when I add the code to housekeeping its says 1532908334.8502. Instead of date and time. Can anyone help me with this?
I have like this:
Code:
$getBans = mysql_query("SELECT * FROM `bans`");
$page_number = $_GET['page_number'];
if(!isset($_GET['page_number']) || !is_numeric($_GET['page_number']))
{
$page_number = 1;
}
$pages = mysql_num_rows($getBans);
$per_page = "15";
$last_page = ceil($pages/$per_page);
if ($page_number < 1)
{
$page_number = 1;
}
else if($page_number > $last_page)
{
$page_number = $last_page;
}
$max = 'LIMIT ' .($page_number - 1) * $per_page .',' .$per_page;
$data_p = mysql_query("SELECT * FROM `bans` ORDER BY `id` DESC $max ");
$next_page = $page_number+1;
$previous_page = $page_number-1;
echo "
<div class='center80'>
<table class='zebra-striped'>
<thead>
<tr>
<th>Ban ID</th>
<th>Type</th>
<th>Value</th>
<th>Reason</th>
<th>Banned By</th>
<th>Expires</th>
<th>More Information</th>
</tr>
</thead>
<tbody>";
if(mysql_num_rows($getBans) == 0)
{
echo("<tr><td>There are no bans to display</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>");
}
else
{
while($ban = mysql_fetch_array($data_p))
{
$banid = $ban['id'];
$bantype = $ban['bantype'];
$banvalue = $ban['value'];
$banreason = $ban['reason'];
$banexpire = $ban['expire'];
$banaddedby = $ban['added_by'];
$banaddedon = $ban['added_date'];
$banappeal = $ban['appeal_state'];
$banuserid = $users->user_Data($banvalue,"id");
echo("<tr><td>".$banid."</td><td>".$bantype."</td><td>".$banvalue."</td><td>".$banreason."</td><td>".$banaddedby."</td><td>".$banexpire."</td><td>");
What should I write in the code to convert it to normal date and time and how should I write it?
Thanks
Re: Convert unix time to readable time in housekeeping
Re: Convert unix time to readable time in housekeeping
@The General
Yeah I have seen that but I don't know how I should write the code... Thats my problem!
EDIT:
I fix it, but I leave in Sweden how do I get + 1 hour in gmdate code?
$banexpire = gmdate('jS F Y h:i:s A (T)', $banexpire); I need to +1 hour.
Re: Convert unix time to readable time in housekeeping
Add this:
PHP Code:
date_default_timezone_set('Europe/Berlin');
German (Berlin) and Sweden are in the same timezone.
Re: Convert unix time to readable time in housekeeping
Quote:
Originally Posted by
Vimsoration
Add this:
PHP Code:
date_default_timezone_set('Europe/Berlin');
German (Berlin) and Sweden are in the same timezone.
After
$banexpire = gmdate('jS F Y h:i:s A (T)', $banexpire);?
Re: Convert unix time to readable time in housekeeping
Change the time of your server. System time of your server is being used to set the timestamp. Change that and all other bans will be correct.