Jump to content


Photo

Need Help changing a script's date/time display


  • Please log in to reply
1 reply to this topic

#1 toasty

toasty
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 17 October 2006 - 01:00 AM

What I'm trying to do with Comikaze is change the display of date/time from "Y-m-d H:i:s" to "l, M j, Y - g:ia T" (ex: Monday, Oct 16, 2006 - 3:18pm PDT).  Normally, this is something I'd expect to be able to do from the script's admin control panel however oddly enough, this is one of the variables that doesn't work when it comes to making changes to it.  Even stranger still is that if I were to believe the CP, the date/time display should be "d M Y h:i a".  However as I just mentioned the date/time that is printed on the news posts follows the "Y-m-d H:i:s" format.  So changes in the CP are (unfortunately) out of the question.

After checking through the script's forum and looking through the source code I was pointed to a fix that goes something like this:

Step 1) Modify the code in the newsDO.class.php file from
Line #291:
$date = $this->_db->DBDate(
    $this->_common->adjustDatetimeTZOffset(date("Y-m-d H:i:s",$time)));
to this
Line #291:
$date = $this->_db->DBDate(date("l, M j, Y - g:ia T",$time));
Step 2) In the MySQL database, in table: comikaze_news, field: time_posted; change the type of field from: "datetime" to "text" and remove the default value of "0000-00-00 00:00:00"

By following these two steps, the date/time display works correctly however I've discovered a "snag" in the fix.  When working correctly each time a new post for a specific comic is made, the news posts are displayed top to bottom from oldest to newest (ascending order).  When this "fix" is applied, as long as the news posts for a given comic are made on the same day, everything works fine.  When the news posts for a given comic are posted over multiple days, their placement gets completely screwed up and it no longer follows an ascending order in accordance to the date and time of the post.  The date/time still appear correctly according to the new format, but they're no longer appearing in chronological order.

I was wondering if anyone might have some ideas as to how to fix this.  Ultimately, all I want is for the news posts to appear in the correct order, and for them to carry the "l, M j, Y - g:ia T" format.

I tried going through every bit of code and changing all occurances of "Y-m-d H:i:s" to "l, M j, Y - g:ia T", but that didn't work.  I have a feeling it has something to do with how it's interacting with the database, maybe that default value of "0000-00-00 00:00:00".  I've included the default newsDO.class.php file incase anyone feels like having a look at it.

If anyone has any thoughts, once again, you'd be saving my butt.  Thanks for your time and help!!  :D

[attachment deleted by admin]

#2 toasty

toasty
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 17 October 2006 - 05:13 AM

On another forum someone pointed out that I should stay away from changing the way the database formats the date and time since having the format of "y-m-d H:i:s" is what allows it to be organized chronolocically.  They then raised the idea that what I want to change is not how the date/time is stored but rather how it's displayed.

That makes perfect sense to me and thus raises the question, "how the hell do I do that?"  I know that there's a .tpl file that is used to display the date/time (in addition to several other variables). In the .tpl file it calls the variable by {NEWS_DATE}. This variable is defined in the "newsDO.class.php" file I included/referenced in my initial post around line #58 where the variable "$time" is translated to "{NEWS_TIME}". My guess is that I need to find where $time is defined or something and make some unknown change there. If the database is recording the news posts "post date" in the "y-m-d h:i:s" it's also displaying it as such... so it seem like it should be easy to tell it to display it as something else... after all, the data isn't changing....

Does anyone have any suggestions what I might have to do to achieve that? I realize I'm probably asking alot and the fact that I didn't write the script does make this a huge pain; but anyone has any suggestions it would totally help me out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users