When I look at the start publishing date of an article in the db I see a datetime stamp that is FOUR hours later than what is displayed in the backend for the article. The site's timezone is set to Los Angeles and I am in Eastern time. I don't see how to get a four hour difference between those except for a few hours when we're changing from Savings Time to Standard Time.

To confuse matters more, the datetime stamp I see when I run code to read the db, regardless of whether not I set the default timezone using date_default_timezone_set('America/Los_Angeles'); is the datetime in the database - not the time displayed in the backend.

For example, a datetime stamp displayed as 2018-10-31 22:11:29 in the backend is stored in the db as 2018-11-01 02:11:29 and comes in from a sql query as 2018-11-01 02:11:29.

This causes some issues under some circumstances when the code tries to display a string based on the publish date. It's too complicated to go into here, but I feel that I must be missing something about how to manage these date values.

  • I recall that Sharky had a recent date tagged post talking about this topic. I am confident that there will be other pages here that speak about properly configuring your datetime stamps. Please continue researching until a volunteer offers specific support. – mickmackusa Dec 25 '18 at 10:07
  • This was the Sharky post that I was thinking of: joomla.stackexchange.com/a/23937/12352 please let us know your global settings and your code that is presenting the time if not from core files. – mickmackusa Dec 25 '18 at 10:14
  • I'm not sure which global settings you are asking about, but the server time zone is set to "America/Los_Angeles". The code in question is located in a custom module. It issues a query to get an article with a publish_up date prior to a "scheduled date". When the publish_up date comes in from the query it is the same as what I can see in the db - which is in UTC. I have tried all kinds of machinations to get this datetime stamp to appear in the correct time (L.A. time) but the DATETIME is STILL UTC. I have also tried converting the publish_up time AFTERwards, but no luck. – user1390379 Dec 31 '18 at 18:43
  • My understading is that a datetime value retrieved from the db (which is in UTC) should be automagically converted to the user timezone (if it is set) or the server time zone. From what I can see, this is not happening. The publish_up DATETIME stamp I see in my code is identical to the value I can see using phpMyAdmin in the db.... which I believe is in UTC. Since my code explicitly sets the timezone to "America/Los_Angeles' AND the server timezone (as displayed in the backend) is also "Los Angeles" AND my user timezone is "Los Angeles" why is the datetime stamp NOT converted to LA time? – user1390379 Jan 8 at 19:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.