×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Comment timestomp

Comment timestomp 14 years 3 months ago #8255

  • phizzy
  • phizzy's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Hello, Ive found next problem: In some cases (unfortunately I cant say which) the post have timestomp with +1 hour compared to real time. Ive checked joomla timezone setting and the usertimezone setting. Well both of them are correct and the same. The incorrect time was assigned to the reply post to other user post. Later done, the reply to another user post has correct timestomp (no settings have been changed). So I cant say all replies have bad timestomp. It happens just in unknown conditions :( I dont uderstand it. Ill be watching for it and Ill post closer findings If Ill can.
Im running Joomla 1.5.15 no legacy mode and JoomlaComment 4.0 beta2

Comment timestomp 14 years 3 months ago #8259

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey there! I just tested it with the same system - Joomla 1.5.15 and joomlacomment beta2. I could not find the problem you are describing.

The comments had all the right time. I'll be happy if you could give me some more information.

Comment timestomp 14 years 3 months ago #8260

  • phizzy
  • phizzy's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
So now I know whats the problem. The situation is this: All posts have good timestomp. But registered users who havent set language in their profiles yet see all timestomps -1 hour (my joomla instalation has global setup UTC+1, so the mentioned users see just timestomps in UTC probably) and it happens even if their profiles have set corresponding timezone (UTC+1 in my case). So it seems like joomlacomment doesnt accept users timezone until he has both timezone and language set in his profile. Wouldnt it be better if the comments timestomps are interpreted with time according to joomla timezone, not to users timezone?

Comment timestomp 14 years 3 months ago #8264

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
phizzy wrote:

... Wouldnt it be better if the comments timestomps are interpreted with time according to joomla timezone, not to users timezone?


Simply, no. The idea is that the timestamps adjust to the logged-in users' timezone. But maybe it could be better to use JavaScript to find the timezone...

Comment timestomp 14 years 3 months ago #8265

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
JonusC could you confirm the bug?

It doesn't matter if you use php or javascript, but simple - php is better. Why use javascript where it is not really needed?

Comment timestomp 14 years 3 months ago #8267

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
It's not really a bug - just an annoyance. If a member joins a Joomla+CB+JC site and does not set their timezone correctly, the dates will show a wrong hour on all the comments. You are right for obvious reasons in that it's of course better to do PHP, but JavaScript was worth mentioning because it retrieves the current time and date from the web browser (the users system clock) instead of server time and can detect timezone based on that. I used JavaScript time methods for the realtime relative date/time display code in the work-in-progress skin for that reason - it's easier to be correct to the user. But it also required every member profile to be on GMT +0 otherwise then it would be wrong again...

...still, JavaScript doesn't help because we of course want to store the dates in the database. I remember there being some strange date/time issues I came across, but I can't remember what they are. phizzy may be right, let me try testing - we may have to add an option for JoomlaComment to use Joomla global timezone if a logged-in user has not set their zone (i.e. their profile is still set to default value).

Alternatively phizzy, make your site require users to set a language and timezone at signup (C.B. registration) - maybe add a banner/text reminder to users to double-check their locale settings for "a better, accurate user experience" ;)

Comment timestomp 14 years 3 months ago #8270

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
...do you have daylight savings? I noticed it isn't aware of DST.

Comment timestomp 14 years 3 months ago #8276

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Daylight savings this could be.

I'll explain how the date is stored and shown.
First thing, when the user posts a comment we do the following:
$createdate = JFactory::getDate();
$createdate = $createdate->toMySQL();

so we save the date without any timestamp. Just as the server give it to us.

The this functions takes care about the output everywhere:
/*
	 * Function to display the Date in the right format with Offset
	 */
	function getLocalDate($strdate,$format='%Y-%m-%d %H:%M:%S') {
 
		jimport('joomla.utilities.date');
		$user =& JFactory::getUser();
 
		//	    if we have an anonymous user, then use global config, instead of the user params
		if($user->get('id')) {
			$tz = $user->getParam('timezone');
		} else {
			$conf =& JFactory::getConfig();
			$tz = $conf->getValue('config.offset');
		}
 
		$jdate = new JDate($strdate);
		$jdate->setOffset($tz);
		$formatDate = $jdate->toFormat($format);
		return $formatDate;
	}

If the user is not logged in, then we output the default date.
If the user is logged in, then we get the user timezone.

If the user didn't specify a timezone, then we will have 0 for timezone, but this is also fine.

All dates for the user will look the same. It is impossible that one commnet is with +1h timezone and another one with -10h timezone, because all comments will be outputed through the same function.

Comment timestomp 14 years 3 months ago #8311

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
Well... the time/date is stored in the database like this...
2009-11-03 02:20:16
...perhaps it could be saved in UNIX Time instead. What timezone is that stored in? Cannot tell. And what happens if the user changes Joomla global timezone, or moves to a new server in a different timezone? It can be fixed yes, but... well I don't know about you, but timezone conversions give me headaches... UNIX Time is always UTC (+0000) and that's the main thing we need. Timezone neutrality in database timestamps.
  • Page:
  • 1
Time to create page: 0.175 seconds