I have a custom module that displays today's date and time:

t('Today: ') . date('d F - H:i')

When I change a user's time zone on their account page the time is 'magically' outputted correctly.

How does Drupal do this?

2 Answers 2


The magic comes from PHP's date_default_timezone_set():

Sets the default timezone used by all date/time functions in a script

Drupal uses it in


I've never seen the code itself, but it likely uses this: https://www.php.net/manual/en/datetime.settimezone.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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