default timezone in PHP

前端 未结 4 621
礼貌的吻别
礼貌的吻别 2021-01-14 08:42

What is default timezone in php? I checked it in the php.ini which shows the following with the timezone is left blank:

[Date]
; Defines the default timezone         


        
相关标签:
4条回答
  • 2021-01-14 08:48

    PHP 7 Answer

    Modern versions of PHP (>= 5.4.0) use the following steps until a default timezone is found:

    1. Reading the timezone set using the date_default_timezone_set() function (if any)

    2. Reading the value of the date.timezone ini option (if set)

    3. If none of the above succeed, the default timezone will be UTC.

    The TZ environment variable is no longer used.

    Source: https://www.php.net/manual/en/function.date-default-timezone-get.php

    0 讨论(0)
  • 2021-01-14 08:55
    ;date.timezone =
    ; This is diasable text
    This is working text
    

    Get it? with this ; On some ini files you can disable some scripts/codes. You can set your time zone in php like: date_default_timezone_set('Europe/London'); And other like Europe/Amsterdam... Read more on php default timezone

    0 讨论(0)
  • 2021-01-14 08:57

    A simple code you have to write for the default timezone. which is:

    date_default_timezone_get()
    

    Now how to use:

    You have to pass the timezone in this function like we want to set India timezone as default see:

    date_default_timezone_set("Asia/Kolkata"); 
    

    Now, whenever you would use date(), automatically return India timezone.

    I would refer if you want a example: how to convert default date timezone in php

    0 讨论(0)
  • 2021-01-14 09:01

    When not specified date.timezone defaults to the system environment variable TZ. You can use this code to check your default value date_default_timezone_get().

    Further info can be found here: http://www.php.net/manual/en/function.date-default-timezone-get.php

    0 讨论(0)
提交回复
热议问题