当前位置:网站首页>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 .
边栏推荐
- 目标检测中的多尺度特征结合方式
- MFC radio button grouping
- Take you to tiktok. That's it
- Capturing packets to find repeated acks and a large number of TCP retransmissions in TCP sessions -- sack (selective acknowledgement) technology
- 深度学习------卷积(conv2D)底层
- C Scrollview scroll up or scroll down
- What are open source software, free software, copyleft and CC? Can't you tell them clearly?
- socket编程(多线程)
- 6-闪耀的激光-CALayer 的应用
- 复选框的基本使用与实现全选和反选功能
猜你喜欢

Tensorboard的使用

建立一有序的顺序表,并实现下列操作: 1.把元素x插入表中并保持有序; 2.查找值为x的元素,若找到将其删除; 3.输出表中各元素的值。

Create an orderly sequence table and perform the following operations: 1 Insert element x into the table and keep it in order; 2. find the element with the value of X, and delete it if found; 3. outpu

图像分割-改进网络结构

Does huangrong really exist?

socket编程(多进程)

PHP file contains -ctf

QT irregular shape antialiasing

观察者模式

Interview questions of a company in a certain month of a certain year (1)
随机推荐
ArcMap batch delete points closer
Hackers use new PowerShell backdoors in log4j attacks
Commonly used bypass methods for SQL injection -ctf
Vulnhub | DC: 3 |【实战】
Check the file through the port
一秒钟查看一次文件,并将文件最后一行内容结果发送至syslog服务器
Structure and usage of transform
What are open source software, free software, copyleft and CC? Can't you tell them clearly?
A record of "from scratch" in college student accounts
观察者模式
The kernel fails to shut down when the easygbs program stops. How should I optimize it? [code attached]
Explanation on webrtc's stun/turn service in tsingsee green rhino video
【Try to Hack】ip地址
船长阿布的灵魂拷问
C# 内存法复制图像bitmap
socket编程(多进程)
Moodle e-learning platform fixes the session hijacking error that leads to pre authorized rce
C Scrollview scroll up or scroll down
domain controller
MySQL brochure notes 5 InnoDB record storage structure