Page 1 of 1
Convert post_time
Posted: Thu Aug 04, 2005 10:36 pm
by zyberjock
hi everyone, anybody here who knows how I can convert phpbb's post_time into a valid date so that i can use the data.
phpbb post_time's stored value is in this format 1115801821 and i want to just get the Date(August, 2, 2005) thats all.
anyone who can give me a function or sumthing that i can use.
Thanks.
Posted: Thu Aug 04, 2005 10:38 pm
by feyd
I believe phpbb uses
gmdate() natively to format all dates...
Posted: Thu Aug 04, 2005 10:44 pm
by feyd
Code: Select all
//
// Create date/time from format and timezone
//
function create_date($format, $gmepoch, $tz)
{
global $board_config, $lang;
static $translate;
if ( empty($translate) && $board_config['default_lang'] != 'english' )
{
@reset($lang['datetime']);
while ( list($match, $replace) = @each($lang['datetime']) )
{
$translate[$match] = $replace;
}
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
}
phpbb's function to do date's (as of phpbb 2.0.12) I believe.. not sure if it's changed since then..
Posted: Thu Aug 04, 2005 10:53 pm
by zyberjock
feyd wrote:Code: Select all
//
// Create date/time from format and timezone
//
function create_date($format, $gmepoch, $tz)
{
global $board_config, $lang;
static $translate;
if ( empty($translate) && $board_config['default_lang'] != 'english' )
{
@reset($lang['datetime']);
while ( list($match, $replace) = @each($lang['datetime']) )
{
$translate[$match] = $replace;
}
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
}
phpbb's function to do date's (as of phpbb 2.0.12) I believe.. not sure if it's changed since then..
i have that code but it really is very complicated for me, with all those variables i mean what i want to do is just to get the number of posts for a specific month but i cant understand some codes like where does board_config come from and every other parameters or variables that phpbb used.
I have tried gmdate and inserted a sample data like in this code
Code: Select all
<?php
$gmepoch = 1116354393;
$format = "D M d, Y g:i a";
$tz = 8;
echo gmdate($format, $gmepoch + (3600 * $tz);
?>
but it resulted in
Parse error: parse error in F:\sample.php on line 7
can you help me fix this.
Thanks
Posted: Thu Aug 04, 2005 10:56 pm
by feyd
your test is missing a closing paren.
Posted: Thu Aug 04, 2005 10:59 pm
by zyberjock
feyd wrote:your test is missing a closing paren.
oh how could i possibly miss that.. i must be really confused with php anyway im just trying out codes and im not really a php guy but i want to be one, and phpbb is the one that im experimenting with, hehe
Anyway Thanks feyd.