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.100 seconds

For starters it's just so easy to design an app in a way that I'm used to i.e. database first then views followed by customization. The fork system is pure brilliance from a developer standpoint as I can override things and still add and update my projects with minimal effort! Truly amazing to be able to build components in Joomla using incremental refinement without having to do everything by hand. Thanks for the great tool! I am so much more productive now than ever and I can't imagine building components any other way!!!!
Dave (Forum)

Get Started