1

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

0

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

0

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 that you have read and understand our privacy policy and code of conduct.

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