error : format_date ()

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
thatsawan
PHP VIP Members
PHP VIP Members
โพสต์: 28508
ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
ติดต่อ:

error : format_date ()

โพสต์ที่ยังไม่ได้อ่าน โดย thatsawan »

แบบนี้จะได้วันที่ปัจจุบัน ตามรูปแบบที่เลือก

โค้ด: เลือกทั้งหมด

 function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum')
        {
                global $user;
                $this->template->assign_vars(array(         
                               'TOTAL_TIME_LOGGED_IN'   => $user->format_date(time(), $format, true),                
                    ));
        }
2014-09-09_22-26-51.png
2014-09-09_22-26-51.png (24.49 KiB) Viewed 1014 times
ถ้าจะให้ เเสดงวันที่จาก ฟิลด์ที่เราเก็บ

โค้ด: เลือกทั้งหมด

$this->template->assign_vars(array(
'TOTAL_TIME_LOGGED_IN'      => $user->format_date($user->data['user_dateformat']),
  ));
error
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (@F jS, Y, g:i a) at position 0 (@): Unexpected character' in E:\xampp\htdocs\phpbb_rc2_new\phpbb\datetime.php:50 Stack trace: #0 E:\xampp\htdocs\phpbb_rc2_new\phpbb\datetime.php(50): DateTime->__construct('@F jS, Y, g:i a', Object(DateTimeZone)) #1 E:\xampp\htdocs\phpbb_rc2_new\phpbb\user.php(713): phpbb\datetime->__construct(Object(phpbb\user), '@F jS, Y, g:i a', Object(DateTimeZone)) #2 E:\xampp\htdocs\phpbb_rc2_new\ext\midphp\m_user_online_time\event\listener.php(80): phpbb\user->format_date('F jS, Y, g:i a') #3 [internal function]: midphp\m_user_online_time\event\listener->page_header(Object(phpbb\event\data)) #4 E:\xampp\htdocs\phpbb_rc2_new\vendor\symfony\http-kernel\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php(457): call_user_func(Array, Object(phpbb\event\data)) #5 [internal function]: Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher->Symfony\Component\HttpKernel\Debug\{clos in E:\xampp\htdocs\phpbb_rc2_new\phpbb\datetime.php on line 50
ภาพประจำตัวสมาชิก
thatsawan
PHP VIP Members
PHP VIP Members
โพสต์: 28508
ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
ติดต่อ:

Re: error : format_date ()

โพสต์ที่ยังไม่ได้อ่าน โดย thatsawan »

ถ้าเเบบนี้ ไม่ error

โค้ด: เลือกทั้งหมด

 $this->template->assign_vars(array(
                        
   'TOTAL_TIME_LOGGED_IN'       => $user->format_date($user->data['user_online_time'], $format, true),
 )); 
เเต่แสดงวันที่ผิด January 1st, 1970, 7:58 am
ภาพประจำตัวสมาชิก
thatsawan
PHP VIP Members
PHP VIP Members
โพสต์: 28508
ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
ติดต่อ:

Re: error : format_date ()

โพสต์ที่ยังไม่ได้อ่าน โดย thatsawan »

เจอะกับปัญหานี้อีก รอบ!!~
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Google [Bot] และบุคลทั่วไป 8