当前位置:网站首页>Set the time zone in ci4 (CodeIgniter 4)
Set the time zone in ci4 (CodeIgniter 4)
2022-06-23 08:14:00 【Passing years】
One 、 Origin
stay PHP In programming , We often need to get the current time , But in CodeIgniter4( hereinafter referred to as CI4) The default time in is America/Chicago .
Then it will be very painful , Use the following code
echo date('Y-m-d H:i:s');The output is (Chicago It's West 6 District )
2022-01-11 21:06:25
But the actual East eighth district is
2022-01-12 11:06:25
Two 、 To solve the process
Surfing the Internet , Find two ways , I think they are all troublesome , But you can sum it up
Method 1
stay php.ini Find data.timezone= Remove the one in front of it ; Number , Then set the data.timezone= “Asia/Shanghai”.
Method 2
In use date() Add a line before the function
date_default_timezone_set("Asia/Shanghai");3、 ... and 、 Personally, I feel that CI4 A better way
The two methods mentioned above , I feel a little troublesome ,
Method 1 if you forget when configuring a new environment , The data output or stored in the database will be ruined .
In method 2, add the line before use , It is troublesome to write code .
But in CI4 in , Can be in .env Add a line to the file , It can be solved
app.appTimezone = "Asia/Shanghai"
Four 、 At the end
CI4 This frame and PHP I don't know much , But a search came down about CI4 There are still few articles , Even there is no introduction to the time zone , So I plan to write this article to give future students less detours when they encounter this problem , We make progress together .
边栏推荐
- imperva-查找正则匹配超时的方法
- Ignore overlength parameter violation
- On ThreadLocal and inheritablethreadlocal, source code analysis
- php序列化和反序列化-ctf
- 81 sentences worth repeating
- 顺序表课设
- Interview questions of a company in a certain month of a certain year (1)
- socket编程——select模型
- PHP serialization and deserialization CTF
- 如何在conda虚拟环境开启jupyter-notebook
猜你喜欢
随机推荐
AVL树的实现
SQL注入常用到的绕过方式-ctf
openvino系列 18. 通过OpenVINO和OpenCV实现实时的物体识别(RTSP,USB视频读取以及视频文件读取)
【Try to Hack】ip地址
忽略超长参数违规
domain controller
套接字socket编程
ThreadPoolExecutor线程池实现原理与源码解析
After easynvr video is enabled, no video file is generated. How to solve this problem?
C# 内存法复制图像bitmap
@Controller和@RestController的区别?
MySQL brochure notes 5 InnoDB record storage structure
开源软件、自由软件、Copyleft、CC都是啥,傻傻分不清楚?
MFC radio button grouping
Cloud computing "half peak"
Implementation principle and source code analysis of ThreadPoolExecutor thread pool
Using jetpack datastore for data storage
转盘式视觉筛选机及其图像识别系统
Markdown learning
List接口三个子实现类









