PHP日期和时间函数。 中的 date_defaul

首页 / PHP入门教程 / PHP日期和时间函数。 中的 date_defaul

date_default_timezone_set() - 语法

bool date_default_timezone_set ( string $timezone_identifier )

它设置脚本中所有日期/时间函数使用的默认时区。

timezone_identifier      -  有效的时区字符串。

链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-default-timezone-set.html

来源:LearnFk无涯教程网

date_default_timezone_set() - 返回值

如果TIMEZONE_IDENTIFIER无效,则返回FALSE,否则返回TRUE。

date_default_timezone_set() - 示例

<?php
   echo "Old time zone is ". date_default_timezone_get(). "\n";
   
   $timeZone='America/Costa_Rica';
   
   if( date_default_timezone_set( $timeZone) ){
      # Now get this time zone.
      echo "New time zone is ". date_default_timezone_get(). "\n";
   }
?> 

这将产生以下输出-

Old time zone is America/Denver
New time zone is America/Costa_Rica

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

技术领导力实战笔记 -〔TGO鲲鹏会〕

玩转Git三剑客 -〔苏玲〕

现代C++编程实战 -〔吴咏炜〕

系统性能调优必知必会 -〔陶辉〕

如何落地业务建模 -〔徐昊〕

大数据经典论文解读 -〔徐文浩〕

编程高手必学的内存知识 -〔海纳〕

超级访谈:对话张雪峰 -〔张雪峰〕

结构执行力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)