Date function problem :/...

Started by Hyperion (noobKID), April 01, 2013, 07:43:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hyperion (noobKID)

hmm, okay. thanks anyways...

i'll try the logs for now then...

poco_digo

Look into Apache log, it may there was an error at the same time u posting the news and the date hasn't been fucked.
Maybe.....

luck

Hyperion (noobKID)

i just dont get it, why would it work with a simple date, instead of Yesterday/Right now show?...

i have not even touched the freaking DST haha, makes no sence! X)...

poco_digo


Hyperion (noobKID)

hmm, funny. i tried go into the config file and change (time_use_relative) to 0, so it would not say (Posted right now), but instead (the date it was posted on). and that worked...

maybe something wrong in the function-code?...

poco_digo

Most likely you have a mismatch of time with the mysql server, when you've posted [1364841406] 04/01/2013 6:36:46 exceeds the current time. has u change de DST?
Luck

Hyperion (noobKID)

#1
when im posting a new news item in the admin-section, i check my database, and the time DID get in. my problem is that it will NOT show the date/time in output like below in the attached picture.

i have chosen LONG as my default when it's getting out of the table/db.
now my annoying problem is that how to fix?...

its been working before, and i have no clue how to fix...
this is my function/s\ i use:

Code (php) Select

function get_time_offset() {
global $CURUSER, $MT;
$r = 0;

$r = ( ($CURUSER['time_offset'] != "") ? $CURUSER['time_offset'] : $MT['time_offset'] ) * 3600;

if ( $MT['time_adjust'] )
{
$r += ($MT['time_adjust'] * 60);
}

if ( $CURUSER['dst_in_use'] )
{
$r += 3600;
}

return $r;
}

function get_date($date, $method, $norelative = 0, $full_relative = 0)
{
global $MT;

static $offset_set = 0;
static $today_time = 0;
static $yesterday_time = 0;
$time_options = array(
'JOINED' => $MT['time_joined'],
'SHORT'  => $MT['time_short'],
'LONG'   => $MT['time_long'],
'TINY'   => $MT['time_tiny'] ? $MT['time_tiny'] : 'j M Y - G:i',
'DATE'   => $MT['time_date'] ? $MT['time_date'] : 'j M Y'
);

if ( ! $date )
{
return '--';
}

if ( empty($method) )
{
$method = 'LONG';
}

if ($offset_set == 0)
{
$GLOBALS['offset'] = get_time_offset();

if ( $MT['time_use_relative'] )
{
$today_time     = gmdate('d,m,Y', ( time() + $GLOBALS['offset']) );
$yesterday_time = gmdate('d,m,Y', ( (time() - 86400) + $GLOBALS['offset']) );
}

$offset_set = 1;
}

if ( $MT['time_use_relative'] == 3 )
{
$full_relative = 1;
}

if ( $full_relative and ( $norelative != 1 ) )
{
$diff = time() - $date;

if ( $diff < 3600 )
{
if ( $diff < 120 )
{
return '< 1 minute ago';
}
else
{
return sprintf( '%s minutes ago', intval($diff / 60) );
}
}
else if ( $diff < 7200 )
{
return '< 1 hour ago';
}
else if ( $diff < 86400 )
{
return sprintf( '%s hours ago', intval($diff / 3600) );
}
else if ( $diff < 172800 )
{
return '< 1 day ago';
}
else if ( $diff < 604800 )
{
return sprintf( '%s days ago', intval($diff / 86400) );
}
else if ( $diff < 1209600 )
{
return '< 1 week ago';
}
else if ( $diff < 3024000 )
{
return sprintf( '%s weeks ago', intval($diff / 604900) );
}
else
{
return gmdate($time_options[$method], ($date + $GLOBALS['offset']) );
}
}
else if ( $MT['time_use_relative'] and ( $norelative != 1 ) )
{
$this_time = gmdate('d,m,Y', ($date + $GLOBALS['offset']) );

if ( $MT['time_use_relative'] == 2 )
{
$diff = time() - $date;

if ( $diff < 3600 )
{
if ( $diff < 120 )
{
return '< 1 minute ago';
}
else
{
return sprintf( '%s minutes ago', intval($diff / 60) );
}
}
}

if ( $this_time == $today_time )
{
return str_replace( '{--}', 'Today', gmdate($TBDEV['time_use_relative_format'], ($date + $GLOBALS['offset']) ) );
}
else if  ( $this_time == $yesterday_time )
{
return str_replace( '{--}', 'Yesterday', gmdate($MT['time_use_relative_format'], ($date + $GLOBALS['offset']) ) );
}
else
{
return gmdate($time_options[$method], ($date + $GLOBALS['offset']) );
}
}
else
{
return gmdate($time_options[$method], ($date + $GLOBALS['offset']) );
}
}//ending date function...


any ideas/suggestions would be AWSOME!...

-thanks! :)...


EDIT:

this is my HTML-OUT of the Database from admin-page.. just if anyone have any ideas...

Code (php) Select

$main_query = "
SELECT
mod_news.nid,
mod_news.added,
mod_news.headline,
users.username
FROM
mod_news
LEFT OUTER JOIN users ON mod_news.u_id = users.u_id";

$main_result = mysql_query ($main_query) or sqlerr(__FILE__,__LINE__);

$HTMLOUT .= "<table border='0' class='table_center' width='100%' cellspacing='1px' align='center'>";
if(mysql_num_rows($main_result) >= 1)
{
$HTMLOUT .= "<tr>";
$HTMLOUT .= "<td><b>#ID</b></td>";
$HTMLOUT .= "<td><b>News Headline</b></td>";
$HTMLOUT .= "<td><b>Added</b></td>";
$HTMLOUT .= "<td><b>By</b></td>";
$HTMLOUT .= "<td><b>EDIT</b></td>";
$HTMLOUT .= "<td><b>DELETE</b></td>";
$HTMLOUT .= "<td><b>INFO</b></td>";
$HTMLOUT .= "</tr>";

while ($main_row = mysql_fetch_array ($main_result))
{

$date = get_date( $main_row['added'], 'LONG' ) . "\n";

$HTMLOUT .= "<tr>";
$HTMLOUT .= "<td>".$main_row['nid']."</td>";
$HTMLOUT .= "<td>".$main_row['headline']."</td>";
$HTMLOUT .= "<td>".$date."</td>";
//$HTMLOUT .= "<td>".$main_row['username']."</td>";
$HTMLOUT .= "<td>Hyperion</td>";

$HTMLOUT .= "
<td>
<span class='row1_box_links'>
<a href='admin.php?action=news&mode=update&newsid=".$main_row['nid']."'>EDIT</a>
</span>
</td>";

$HTMLOUT .= "
<td>
<span class='row1_box_links'>
<a href='admin.php?action=news&mode=delete&newsid=".$main_row['nid']."'>DELETE</a>
</span>
</td>";

$HTMLOUT .= "
<td>
<span class='row1_box_links'>
<a href='admin.php?action=news#'>INFO</a>
</span>
</td>";
$HTMLOUT .= "</tr>";
}
}
else
{
$HTMLOUT .= "<tr>";
$HTMLOUT .= "<td>No news items to be shown here...</td>";
$HTMLOUT .= "</tr>";
}
$HTMLOUT .= "</table>";


-thanks again! :).

[attachment deleted by admin]