Time Zone

Need help with the Administration of your Joomla! 1.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Tue Sep 01, 2009 1:59 pm

ooffick wrote:If the timezone is set to Timezone: UTC+2, how are yvComment, Acajoom reacting?
Olaf

See example:
http://test2.frustless.de/index.php/not ... /2513.html

j conf +2
personal +2
serv +2

article displays time +2 hours relatively local (right) time

yvcomment creates comment with created time -2 hours relatively local (right) time and displays it with right local time by setting above (so, if article displays time +2 hours).

either article has a right time, nor a comment :-((

Leon

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11616
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Time Zone

Post by ooffick » Tue Sep 01, 2009 2:32 pm

ok, so set it to the correct option +2, and leave it there.

With this setting the time of the comments are correct, right?

If so, use the following output overwrite, to create the right time for the article:
  1. create a folder in your template folder called "html" (if it doesn't exists)
  2. create a folder in that html folder called "com_content" (if it doesn't exists)
  3. create a folder in that com_content folder called "article" (if it doesn't exists)
  4. copy the file .../components/com_content/views/article/tmpl/default.php in this .../templates/[your-template]/html/com_content/article/ folder
  5. open that file
  6. find the following lines:

    Code: Select all

    <?php echo JHTML::_('date', $this->article->created, JText::_('DATE_FORMAT_LC2')) ?>
  7. and replace it with the following:

    Code: Select all

    <?php echo JHTML::_('date', $this->article->created, JText::_('DATE_FORMAT_LC2'),0) ?>
  8. save the file
This should fix the creation date of the article in the article view.
You might need to play around with the last value:

Code: Select all

<?php echo JHTML::_('date', $this->article->created, JText::_('DATE_FORMAT_LC2'),-2) ?>
Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
yvolk
Joomla! Guru
Joomla! Guru
Posts: 979
Joined: Thu Jun 01, 2006 1:52 pm
Location: Moscow, Russia
Contact:

Re: Time Zone

Post by yvolk » Tue Sep 01, 2009 3:09 pm

Hello, let me add 2 Eurocents to your discussion :)
1. Please see my recent bug report at JoomlaCode
- it clearly shows that Joomla! code is not consistent in dealing with "created" and "modified" dates of the Articles. Hence the bug in Joomla! core.

To fix it we need to patch Joomla! in the places where it set that "created" and "modified" dates.

2. As I figured out from your discussion, yvComment acts as expected now, so we may safely use this code to determine the rigth value for current date in MySQL format:

Code: Select all

jimport('joomla.utilities.date');
$jnow = new JDate();
$now = $jnow->toMySQL();
The resulted value: $now - may be used to set "created" and "modified" dates,
e.g. in file "components/com_content/models/article.php" you should change

Code: Select all

$article->created = gmdate('Y-m-d H:i:s');
to

Code: Select all

jimport('joomla.utilities.date');
$jnow = new JDate();
$now = $jnow->toMySQL();
$article->created = $now;
Changing template file, as Olaf proposed, is only partial solution, because you will still have inconsistency (in fact, erroneous dates) in the database...
Text of all my messages is available under the terms of the GNU Free Documentation License: http://www.gnu.org/copyleft/fdl.html

lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Tue Sep 01, 2009 3:37 pm

Hi, Olaf!

Thank you very much!

At least, I have hidden the problem with your solution: the site now looks "normal" out.

But this is only "view" :( .
The inner is unfortunately not to be changed: there are settings in Joomla that are not understandable and do not work properly.

It really should be a general "joomla-time" , on which must be based all its extensions.

But you have nothing to do with this.

Thanks again!

lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Tue Sep 01, 2009 3:44 pm

yvolk wrote:Hello, let me add 2 Eurocents to your discussion :)
Hi, Yury.

I have not seen your post before I replied Olaf.

Now I will test your solution.

Thank you very much!

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11616
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Time Zone

Post by ooffick » Tue Sep 01, 2009 3:57 pm

I never had any problems with the date and time. But your suggested changes just changing the output to MySQL, right?

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
yvolk
Joomla! Guru
Joomla! Guru
Posts: 979
Joined: Thu Jun 01, 2006 1:52 pm
Location: Moscow, Russia
Contact:

Re: Time Zone

Post by yvolk » Tue Sep 01, 2009 4:19 pm

ooffick wrote:I never had any problems with the date and time. But your suggested changes just changing the output to MySQL, right?

Olaf
The example above effectively change date, that is stored in the database. So article, added through the frontend will have correct time now (the code is from the frontend model file).
PS: I never noticed the problem before also :-\
Text of all my messages is available under the terms of the GNU Free Documentation License: http://www.gnu.org/copyleft/fdl.html

lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Wed Sep 02, 2009 1:05 pm

yvolk wrote: The resulted value: $now - may be used to set "created" and "modified" dates,
e.g. in file "components/com_content/models/article.php" you should change

Code: Select all

$article->created = gmdate('Y-m-d H:i:s');
to

Code: Select all

jimport('joomla.utilities.date');
$jnow = new JDate();
$now = $jnow->toMySQL();
$article->created = $now;
Changing template file, as Olaf proposed, is only partial solution, because you will still have inconsistency (in fact, erroneous dates) in the database...
Hi,

I'm sorry,
but this solution does not work.
without olaf's changing a created date is shown as +2 hours relative real time (with my setting, see above).

Also in DB has created date for a new article + 2 hours.

Thanks.

P.S.

You can test it here: http://test.frustless.de/index.php/notr ... l?inf=3,16

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11616
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Time Zone

Post by ooffick » Wed Sep 02, 2009 1:22 pm

You said earlier that the "inner view" is not changed? What do you mean by that?

Olaf
Olaf Offick - Global Moderator
learnskills.org

lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Wed Sep 02, 2009 4:28 pm

ooffick wrote:You said earlier that the "inner view" is not changed? What do you mean by that?

Olaf
I meant exactly what Yuri said:
Changing template file is only partial solution, because there is inconsistency (in fact, erroneous dates) in the database...
I get false created time (+ 2 hours) for an article in DB, if I create it by frontend.
And with you solution (I use it, thanks :) ) is changed only "view".

Leon

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11616
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Time Zone

Post by ooffick » Wed Sep 02, 2009 5:04 pm

The time in the database is AFAIK treated as GMT time in the database.

My guess would be that there is a plugin which listens on onBeforeContentSave and modifies the date. But I don't know.

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
yvolk
Joomla! Guru
Joomla! Guru
Posts: 979
Joined: Thu Jun 01, 2006 1:52 pm
Location: Moscow, Russia
Contact:

Re: Time Zone

Post by yvolk » Wed Sep 02, 2009 6:38 pm

lemur1 wrote:
ooffick wrote:You said earlier that the "inner view" is not changed? What do you mean by that?

Olaf
I meant exactly what Yuri said:
Changing template file is only partial solution, because there is inconsistency (in fact, erroneous dates) in the database...
I get false created time (+ 2 hours) for an article in DB, if I create it by frontend.
And with you solution (I use it, thanks :) ) is changed only "view".

Leon
Hi Leon, I may suggest 2 things:
1. Debug the code, something like this:

Code: Select all

global $mainframe;
$message = 'point 001, date="' . $article->created  . '"';
$mainframe->enqueueMessage($message, 'notice');
1) just after it is set,
2) before end of the function
...
- to see, what time is stores

2. Try different ways to define the $now date, see e.g. examples in my bug report: there are three different ways to set date of the article, one of them involves timezone offset...
Text of all my messages is available under the terms of the GNU Free Documentation License: http://www.gnu.org/copyleft/fdl.html

lemur1
Joomla! Intern
Joomla! Intern
Posts: 55
Joined: Fri May 09, 2008 8:22 pm

Re: Time Zone

Post by lemur1 » Thu Sep 03, 2009 11:27 am

Thanks to all who took part in the discussion of the problem.
Unfortunately, for working reasons, I can not now continue the experiments (I will use the Olaf's "solution").

Maybe someone else is ready to offer a general solution.

I hope, however, that the problem (will be) noticed by the main developers of Joomla, and will be resolved in the next version of Joomla.

It may be determined a "general"/"single" "Joomla time" for all extensions and a clear algorithm will be presented for computing of this time on the basis of:
- Server time (Zone)
- Joomla -> configuration -> server time Zone
- user -> parameter -> time zone

Leon


Locked

Return to “Administration 1.5”