Jump to content

Need Help changing a script's date/time display


toasty

Recommended Posts

What I'm trying to do with [URL=http://www.comikaze.org]Comikaze[/URL] 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 [b]should[/b] 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[code]Line #291:
$date = $this->_db->DBDate(
    $this->_common->adjustDatetimeTZOffset(date("Y-m-d H:i:s",$time)));[/code]to this[code]Line #291:
$date = $this->_db->DBDate(date("l, M j, Y - g:ia T",$time));[/code]Step 2) In the MySQL database, in [COLOR=DarkRed]table: comikaze_news, field: time_posted[/COLOR]; change the type of field from: [COLOR=DarkRed]"datetime"[/COLOR] to [COLOR=DarkRed]"text"[/COLOR] and remove the [COLOR=DarkRed]default value of "0000-00-00 00:00:00"[/COLOR]

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 [I]on the same day[/I], everything works fine.  When the news posts for a given comic are posted over [b]multiple[/b] 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 [b]something[/b] 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 [b]default[/b] 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]
Link to comment
Share on other sites

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 [b]stored[/b] but rather how it's [b]displayed[/b].

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.
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.