Jump to content

[SOLVED] PHP Date Help, Simple! For you,


Gayner

Recommended Posts

$row['post_date']     = get_date($row['post_date']);

 

That gives me error:

 

Fatal error: Call to undefined function get_date() in C:\wamp\www\forums\sources\Topics.php on line 839

 

$row['post_date'] is like a a whole bunch of numbers

EXAMPLE: "1251363321"

 

I want to convert that into  a Date, how would i? :)

Link to comment
Share on other sites

You are missing a custom function named get_date()

 

Yea i know that function is:

 

function get_date($date = "", $method = "", $override = FALSE, $detailed = false, $noclock = false) {
        global $ibforums;

        if (!$date) {
            return '--';
        }
        if (empty($method)) {
            $method = 'LONG';
        }
        if ($this->offset_set == 0) {
            $this->offset = $this->get_time_offset();
            $this->offset_set = 1;
        }
        if (!isset($this->Date_Replace_Array)) {
            $this->set_time_replace();
        }
        if ($ibforums->vars['use_relative_date'] && !$override) {
            $now = mktime();
            $today = gmdate("F j Y", $now + $this->offset);
            $yesterday = gmdate("F j Y", $now - 86400 + $this->offset);
            $tomorrow = gmdate("F j Y", $now + 86400 + $this->offset);
            $this_date = gmdate("F j Y", $date + $this->offset);
            if ($this_date == $today) {
                if ($noclock) {
                    return $this->lang['rel_today_noclock'];
                }
                else if ($now == $date) {
                    $rel_date = $this->lang['rel_now'];
                    return str_replace("{time}", $now - $date , $rel_date);
                }
                else if ($now - $date > 0 && $now - $date < 60) {
                    $rel_date = $this->lang['rel_seconds'];
                    return str_replace("{time}", $now - $date , $rel_date);
                }
                else if ($date - $now > 0 && $date - $now < 60) {
                    $rel_date = $this->lang['rel_seconds_soon'];
                    return str_replace("{time}", $date - $now , $rel_date);
                }
                else if ($now - $date > 0 && $now - $date < 3600) {
                    $rel_date = $this->lang['rel_minutes'];
                    return str_replace("{time}", round(($now - $date)/60) , $rel_date);
                }
                else if ($date - $now > 0 && $date - $now < 3600) {
                    $rel_date = $this->lang['rel_minutes_soon'];
                    return str_replace("{time}", round(($date - $now)/60) , $rel_date);
                }
                else if ($date - $now > 0){
                    if ($detailed) {
                        $hours = floor(($date - $now)/3600);
                        $minutes = round((($date - $now) % 3600)/60);
                        if ($hours == 1)
                            if ($minutes == 1)
                                $rel_date = $this->lang['rel_today_soon_h_m'];
                            else
                                $rel_date = $this->lang['rel_today_soon_h'];
                        else
                            if ($minutes == 1)
                                $rel_date = $this->lang['rel_today_soon_m'];
                            else
                                $rel_date = $this->lang['rel_today_soon_hm'];
                        $rel_date = str_replace("{hours}", $hours, $rel_date);
                        $rel_date = str_replace("{minutes}", $minutes, $rel_date);
                    }
                    else {
                        $rel_date = $this->lang['rel_today_soon'];
                    }
                    $method = $this->lang['time_format_rel'];
                    $rel_date = str_replace("{time}", gmdate($method, $date + $this->offset) , $rel_date);
                    return $rel_date;
                }
                else {
                    if ($detailed) {
                        $hours = floor(($now - $date)/3600);
                        $minutes = round((($now - $date) % 3600)/60);
                        if ($hours == 1)
                            if ($minutes == 1)
                                $rel_date = $this->lang['rel_today_h_m'];
                            else
                                $rel_date = $this->lang['rel_today_h'];
                        else
                            if ($minutes == 1)
                                $rel_date = $this->lang['rel_today_m'];
                            else
                                $rel_date = $this->lang['rel_today_hm'];
                        $rel_date = str_replace("{hours}", $hours, $rel_date);
                        $rel_date = str_replace("{minutes}", $minutes, $rel_date);
                    }
                    else {
                        $rel_date = $this->lang['rel_today'];
                    }
                    $method = $this->lang['time_format_rel'];
                    $rel_date = str_replace("{time}", gmdate($method, $date + $this->offset) , $rel_date);
                    return $rel_date;
                }
            }
            if ($this_date == $yesterday) {
                if ($noclock) {
                    return $this->lang['rel_yesterday_noclock'];
                }
                $rel_date = $this->lang['rel_yesterday'];
                $method = $this->lang['time_format_rel'];
                return str_replace("{time}", gmdate($method, $date + $this->offset) , $rel_date);
            }
            if ($this_date == $tomorrow) {
                if ($noclock) {
                    return $this->lang['rel_tomorrow_noclock'];
                }
                $rel_date = $this->lang['rel_tomorrow'];
                $method = $this->lang['time_format_rel'];
                return str_replace("{time}", gmdate($method, $date + $this->offset) , $rel_date);
            }
        }
        if ($this->time_options[$method] != "") {
            return Strtr(gmdate((isset($this->lang["time_format_".$method])?
                                     $this->lang["time_format_".$method]:
                                     $this->time_options[$method]
                                 ),
                                ($date + $this->offset) ),
                                $this->Date_Replace_Array);
        } else {
            return Strtr(gmdate($method, ($date + $this->offset) ), $this->Date_Replace_Array);
        }
    }

 

 

I dont want to mess around with all that code because it makes it say "2minutes ago" i dont need that, I want exact date, :D  Could u help me on convertin?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.