Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

22 Hours ago.

lechlech
edited July 2005 in Vanilla 1.0 Help
22 Hours ago? Help, im stuck in time!

Comments

  • note, this was posted on sunday @ 6:34am CST not really 22 hours ago. :) I've placed my bets on one of two scenarios going on. A) mark is screwing with time stamps, or B) somebody found a neat flaw.
  • Stop living in the past lech, you have to face up to the future and move forward
  • haha, you're stuck with me!
  • /me starts to run forward
  • that's kinda weird..
  • houston, we have uh-oh!

  • Yeah, I see the "22 hours ago" thing, too, but it's only on a handful of items. Some items are showing "7 hours ago," etc. However, it appears that only the newest items on the board show up as being "22 hours ago." I made a test post to my own installation, and everything works fine, so something must have changed on mark's server -- presumably his server time (has been set backwards). If the server time has changed, that means that the newest posts are showing up at the top (even though they have a timestamp older than the older posts) because comments/discussions must be ordered by ID rather than date/time. In other words, they're ordered by the order in which they were entered into the database.
  • well, what's even weirder is the fact that the second post to this thread was posted well over 3 hours ago and it's reading off as 1 hour ago.
  • MarkMark Vanilla Staff
    Posting to update the timestamp.
  • MarkMark Vanilla Staff
    Okay. I've figured out what the problem is. For some reason mysql thinks that the current time is two hours from now. When you save a comment or discussion, it uses mysql's "now" function to timestamp the record. When you then pull the record from the database, it compares the time mysql has to the time the server has - and the server says that it is two hours earlier - so my timediff function screws up and says "22 hours ago". Uggghhh. I don't know why mysql is stamping at a different time than the server. I had assumed that mysql would get it's "now" time *from* the server. But I guess that is incorrect. I have a fix for it, but it's a massive pain in the ass.
  • I've found that it's usually better, if users are going to be seeing timestamps, to store times in GMT on the server, and ask users what their timezone is.
  • mark, don't even attempt time difference offsets, i swear to god it will drive you insane and make you as bald as me by the end of the day after you've ripped all your hair out. If anything, save it for an extension and not core, preserve whatever little sanity you may have remaining. I've toyed around manually with these functions in the past, and they are NOT FUN AT ALL.
  • MarkMark Vanilla Staff
    Yeah - I'm not a fan of messing with timezones. My fix was to do a search / replace on all instances of "now()" in the application. So, from this point forward all of the times will be decided by PHP. And for the record, while I'm a big fan of my "x minutes ago" method for stamping posts, it was also a way for me to get away from mucking about with timezones ;)
  • oh and one thing I have noticed, it's most likely limited to this server, because I haven't noticed it elsewhere. The problem seems to have appeared late last night.
  • MarkMark Vanilla Staff
    Oh, and get ready for a big nasty upload...
  • Well, I just said "better", not "funnest" ;) Gotta agree with lech, the first time I did that was a bitch and a half!. But every time since then has been easier, so now I can whip offset functions up in 10 minutes that work just fine - I don't have the list of timezones memorized though ;) But before you ask or I offer, all my code is either ASP or actual VB - I just barely know enough PHP to understand what I'm reading when I look at your source, I can't write that yet.
  • /me braces himself
  • the only simple solution I could offer to localize the timezone for a user is by applying the offset to the users local time, nothing more nothing less. Get the current time zone info and subtract or add the hours/minutes/seconds depending on the timezone in question. After X ammount of days, just stick it to the regular timestamp, but that would reduce some overhead doing all those calculations each time. So it would prove useless as a core feature.
  • I find that it's better to use PHP's time() function and save it to an int field in the database. This way, you don't have to worry about database quirks with date/time or timestamp fields, and you can still properly order by the date or use comparisons on it because it's just a standard number. Then, when you need to display it, you use date('m d, Y H:i:s', $time) and all works well. Or if I user enters a time, and you want to search for it, you just use strtotime() to convert the user-supplied date to a UNIX timestamp (int) and pull the correct records from the database. Database's timestamp columns are problematic at best, and it's hard to port them from one database server to another. Yet, int columns are pretty much uniform across the board.
  • yeah just until 2038 :D but well...on topic...i really hate timezones...dont let them come back...every good new app ive seen in the last weeks follows the way of "x minutes ago" and thats good! :)
This discussion has been closed.