The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Fix vbShout Timezone problem Details »» | |||||||||||||||||||||||||
This vbShout plugin: http://www.vbhackers.com/f76/ajax-fl...ut-2-1-a-4536/
Has a serious bug with Time Zone changing to that of the last person to post in the shout box. Here is a fix so that each user will see the time in their local timezone correctly. 1. Open template forumhome_vbshout_shout Find this (should be at the very beginning): Code:
<tr> Code:
<td nowrap align="left" valign="top"> <font size="1"> <date>{$Shout['time']}</date> </font> </td> 2. Open template forumhome_vbshout Find: Code:
Shouts.innerHTML = '<table cellpadding="1" cellspacing="3" border="0" width="95%" align="left">' + ShoutRequest.handler.responseText + '</table>' Code:
var formatMe = ShoutRequest.handler.responseText formatMe = replaceDates(formatMe); Shouts.innerHTML = '<table cellpadding="1" cellspacing="0" border="0" width="100%" align="left">' + formatMe + '</table>' Find this: Code:
function sb_CollectHV(sbForm) Code:
// replaces <date> tags function replaceDates(s) { var ret = ""; var matches = s.match(/<date>\d+<\/date>/g); for(var i = 0; matches != null && i < matches.length; i++) { var utc = matches[i].match(/\d+/); var date = new Date(utc * 1000); ret = ret + s.substr(0, s.indexOf(matches[i])); ret = ret + (date.getMonth()+1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + ((date.getMinutes() < 10) ? "0" : "") + date.getMinutes() + ":" + ((date.getSeconds() < 10) ? "0" : "") + date.getSeconds() + " "; s = s.substr(s.indexOf(matches[i]) + matches[i].length); } ret = ret + s; return ret; } 3. Open file vbshout.php FInd this (There are similar code blocks, this should be in the function rewrite_shoutbox_flatfile() around line 226): Code:
$Shout['time'] = buildTime($Shout['s_time']); $Shout['s_shout'] = bbcodeparser($Shout['s_shout']); $Shout['style'] = ''; $Shout['data'] = unserialize($Shout['s_data']); $Shout['username'] = fetch_musername($Shout, 'usergroupid'); if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1) { $Shout['data']['color'] = ''; } Code:
// $Shout['time'] = buildTime($Shout['s_time']); $Shout['time'] = $Shout['s_time']; $Shout['s_shout'] = bbcodeparser($Shout['s_shout']); $Shout['style'] = ''; $Shout['data'] = unserialize($Shout['s_data']); $Shout['username'] = fetch_musername($Shout, 'usergroupid'); if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1) { $Shout['data']['color'] = ''; } This should now pass the date as UTC and JavaScript will convert it on the client side to the appropriate date. Show Your Support
|
Comments |
#12
|
|||
|
|||
Quote:
|
#13
|
|||
|
|||
Sorry, I have a lot of custom code on my install.
In that initial template edit, try setting font size="2" instead of size="1", or change the td attributes to otherwise match what your tables look like. Code:
<td nowrap align="left" valign="top"> <font size="1"> <date>{$Shout['time']}</date> </font> </td> |
#14
|
|||
|
|||
Thanks newhere! Loving the support so far!
|
#15
|
|||
|
|||
It's kind of an ugly hack around this static html nonsense. But it works. It was not acceptable to me to have no timestamp on shouts, and it was also not acceptable to have timezone constantly changing to whatever timezone of the last user posting a shout.
|
#16
|
|||
|
|||
Thanks for this...
If anyone had the time showing before and now you've got a bunch of numbers after the date/time and before the name in the forumhome_vbshout_shout, you probably added this line to it Code:
{$Shout['time']} Now how to get rid of the date and just have the time... |
#17
|
|||
|
|||
Didn't see you answer this yet, but is it possible to change it from 24 hour to 12 hour instead?
|
#18
|
|||
|
|||
You can format the date however you want if you know a bit of javascript:
From my post above https://vborg.vbsupport.ru/showpost....6&postcount=10 |
#19
|
|||
|
|||
Quote:
I can delete with the best of the them however.. the date is gone. |
#20
|
|||
|
|||
Quote:
replace Code:
ret = ret + (date.getMonth()+1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + ((date.getMinutes() < 10) ? "0" : "") + date.getMinutes() + ":" + ((date.getSeconds() < 10) ? "0" : "") + date.getSeconds() + " "; Code:
var append = "AM"; var hour = date.getHours(); if(hour > 12) { hour = hour - 12; append = "PM"; } if(hour == 0) { hour = 12; append = "AM"; } ret = ret + "[" + (date.getMonth()+1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + hour + ":" + ((date.getMinutes() < 10) ? "0" : "") + date.getMinutes() + " " + ((date.getSeconds() < 10) ? "0" : "") + date.getSeconds() + " " + append + "]"; |
#21
|
|||
|
|||
Omg perfect!!!! Thanks alot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|