Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

timezone date 15 Jun 2016 11:11 #14070

  • albert
  • albert's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 70
  • Thank you received: 2
Hi,
When i save created date and modified date, the time displayed in the database and in the design is the UTC, i 've read that it takes the timezone from the Joomla user or the one by default.
I checked that, and always is stored and displayed the utc independently of the timezon configured.
How could i solve?

tahnks,
Albert

Please Log in or Create an account to join the conversation.

timezone date 15 Jun 2016 13:48 #14071

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Are you sure of that.

Did you configured correctly the timezone in the user's configuration profile ?

Do you display the date with JDom?
Can you tell us wich project / Table / Layout ? (PTL)
I will have a look, but I think all this is working because I have been working on that recently.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

timezone date 15 Jun 2016 14:05 #14072

  • albert
  • albert's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 70
  • Thank you received: 2
Yes, It is configured correctly.

I do not display the date with dom, i simply take the data from the database and i display.
But i want to store the data +2h in the database, and i do not know where to do?
maybe i should do in the model on the function save?

Please Log in or Create an account to join the conversation.

timezone date 15 Jun 2016 14:11 #14073

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
So, that's the reason why.

No, don't touch the model, don't touch the database.
The date MUST ALWAYS be stored in UTC. Obligation, no way out.

If you store different offsets, then a user could change its user parameters and then your system would be unstable of in some case could affect the security.
NEVER do that.

You need to set the offset every time that you want to display the date.

with a JDate object, you can do :
$date->modify('+2hours');

But the best is to apply the user's offset.
You can check JDom : html.fly.datetime
$user = JFactory::getUser();
$date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));

EDIT : Sorry, I reviewed the code. Now it is better.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Last edit: by admin. Reason: Fixed answer.
  • Page:
  • 1
Time to create page: 0.087 seconds

Real time saver and great Component Builder tool ! I have been developing with J-Cook Pro Component Builder for several months now and can say with all honesty that this product/service is second to none. The product is feature rich and is being improved and added to all the time. Do yourself a favor if you need to build a Joomla! Component then you can do no wrong in trying the product. You will save on time and effort while being able to deliver your project on time. J-Cook pro does the hard work for you you then have the freedom to fully customise the end result for your own needs. 

One word: Awesome.
Edwardcox (JED)
         

Get Started