第 1 頁 (共 1 頁)
[問題] 生日外掛 1.5.7 安裝後,舊資料的生日取出來全亂了(
發表於 : 2005-06-26 05:48
由 momoC
前陣子從 PHPBB Plus 1.3 轉到 2.0.15 ,一切都穩定了下來,加了幾個外掛也都正常無誤,但加了生日外掛後,生日的顯示一直有問題。
整個安裝程序走了三遍,並沒有看到什麼錯誤,但日期就是不對。到資料庫裡看 19701128 會被顯示為 2013.06.05。19800727 會被顯示為 2013.11.30。我修改生日到 1969.03.18 後到資料庫裡去看,看到的是 -289 。
這是正常的嗎?我該自己將會員的生日都重輸入一遍以配合 mkrealdate 所使用的系統 ,還是哪裡裝錯,修正就好了?
發表於 : 2005-06-27 12:34
由 momoC
果然是我的錯,這個故事告訴我們,不要看大家在裝什麼 mod 就一起加,要先看清楚是不是適合自己的站。寫信去問作者,有沒有在外掛中提供另一種不用 mkrealdate() 的選擇(叫我奧客第一名吧!)畢竟PHPBB 用 mkrealdate() 後,這個欄位的日期格式就和其他的欄位都不同了。我可能太挑剔了,同一個系統中有不同的格式,會讓我不太心安,總覺得將來會有什麼麻煩。總之,作者勸我看開點,自己去找 phpbb plus 的程式參考修改。呵呵(汗)
沒人能幫忙想想辦法嗎???

發表於 : 2005-06-27 20:21
由 momoC
對了,這是作者的說明。如果以後也有人有一樣的問題的話。因為我看得有些似懂非懂(PHP 才剛學)就恕我不翻譯了:
The format of the general dates storred into the DB by phpBB2 are UNIX time stamps - how-ever since servers runing on windows maschines does NOT support dates older than 1986, it can not be used for birthdays.
To slove this I have inlcuded 2 functions witch can handle dates back in time (also if runing on windows) these functions does not work with UNIX TIMES STAMPS but almost - it is a UNIX TIME STAMP divided by 86400 (number of secounds in a day) so the number storred in the DB are actual the number of days since 1. jan 1970 (with sign) a date back in 1960 should this way have a negative number.
我正在找日期轉換的公式,看看有沒有可能在讀取資料庫前,自己做小轉換。或是資料庫日期的轉換程式,所以不用自己手動修改。如果有人知道的話,麻煩告知,謝謝囉~
發表於 : 2005-06-28 02:35
由 momoC
後來我決定在資料庫中建個欄位儲存正常生日格式,將 user_birthday 讓給 birthday mod 。在程式中加入維護新建欄位的對應功能,然後自己手改所有的生日。(噢嗚~)從此生日就有兩欄,一欄是 birthday mod 用,一欄顯示正常生日以備不時之需。(其實應該會有轉換程式,我只是求方便)
以上!