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

  I found "cook" two days ago. Played around with it for a day and then within a day got rid of two legacy applications in IBM Lotus Domino Notes and replaced them with "cook". It was really easy. A piece of cake. Actually it was even easier than cooking. Cooking involves more work than developing with "cook". What can I say about "cook"? Great application great price for what it delivers great forum with a lot of information and fast responses active and friendly community fast forward moving development cycle So what should I say "Monsieur Le Cook"? Keep the good work going it will lead to success. Having become a paying member in the words of Edith Piaf may I say ..... non rien de rien ... je ne regrette rien. Vive La France.
FK (JED)
         

Get Started