Have a site registering users. The user record in the CP says they registered at 11:39 June 12.

The database 'dateCreated' says 10:39.

The site settings timezone are UTC+1 BST.

PHP config date.timezone is Europe/London (actual location) and Default timezone is UTC.

If I turn off UTC +1 in Craft timezone settings to UTC then front end user record matches database.

What I can't figure out for sure is what time did they really register? :)

  • I just learned to kinda live with it. Here in the Netherlands, 1 hour ahead of London time I have the same issue but then 2 hours ahead. Tagging along here for when there is an explanation / solution. What I'm thinking is that the amount of + hours of UTC just gets added aswell to the time it should be. Jun 13 '17 at 15:21
  • It looks like the server/db time is the 'real' local time and the interface just makes a change in date when setting timezone is changed. Which is a bit weird for time sensitive content.......or embargoed press releases...
    – joomkit
    Jun 13 '17 at 16:33

Craft stores all dates in UTC to the database, no matter what timezone you configure in settings.

When (user) models are populated, e.g. for use in the CP, DateTime objects are created from these values and the objects’ timezones are set to the one you configured.

If you want to output a user’s dateCreated attribute in a date format that includes the timezone you can easily do that in a template using the date Twig filter. This will return the date in ISO 8601 format using your configured default timezone.

{{ user.dateCreated|date('c') }}

You can also output the date formatted for a diffenent timezone.

{{ user.dateCreated|date('c', 'Europe/Paris') }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.