简体   繁体   中英

setlocale doesn't work properly in my timezone

I live in Bangladesh. But when I use this code. <?php setlocale(LC_ALL,"asia/dhaka"); echo strftime("%d %B %Y"); ?> <?php setlocale(LC_ALL,"asia/dhaka"); echo strftime("%d %B %Y"); ?> Result shows US Timezone. I want to change my timezone.

Locale and time zone are not the same concept. For example, one can have a US English locale and have their clock set to Japan's local time (perhaps they are traveling).

For PHP, use the date_default_timezone_set function to set the time zone - not the setlocale function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM