Nick
Nick

Reputation: 1248

date_default_timezone_set or ini_set(date.timezone) for Php7

Both work, but what is the current recommended way for my version? I wish to simply set UTC and avoid strict errors.

My setup would be

index.php calls config.php, config has date_default_timezone_set / ini_set;

No more classes ever warn about lack of timezone.

Does it matter? Both work.

Upvotes: 1

Views: 1361

Answers (2)

Facedown
Facedown

Reputation: 192

You should probably set both, because you never know whether someone use ini_get('date.timezone') or date_default_timezone_get(). These results may differ.

Upvotes: 0

John Conde
John Conde

Reputation: 219864

It doesn't matter as both perform the same function, and as function calls, have the same overhead.

However, in an ideal situation you would set this in your php.ini file which is parsed once at start up and then stored in memory which would be more performant overall.

Upvotes: 1

Related Questions