php time()使用date函数本地电脑和服务器时间不一样
最近配置了一台wamp环境的服务器,但发现时间与本地时间是地区别的,并且 利用time获取的时间再利用date显示有时差的,下面我们一起来导致原因与解决办法。
如果date时间不一致可以使用date_default_timezone_set设置时区:
代码如下 | 复制代码 |
";
//对当前时间进行计算
echo date('Y-m-d H:i:s',time()-600); //减10小时
echo " "; //时间戳转时间 echo date('Y-m-d H:i:s',1364277600); //时间转时间戳(仅精确到秒) echo strtotime("2013-03-26 14:00"); echo " "; ?> |
方法一:
date_default_timezone_set('PRC');
没有返回值。下面再直接使用date函数就OK了
$time = date(Y."年".m."月".d."日".G."时".i."分");
方法二:
修改php.ini中的;date.timezone = 为date.timezone = "Asia/Shanghai"(或者改为date.timezone = “PRC”)并去掉前面的分号,重启Apache即可。
**一定记得加上引号哦

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How to achieve login authorization from within the application to outside the application? In some applications, we often encounter the need to jump from one application to another...

This article provides a complete guide to login and registration on Binance PC version. First, we explained in detail the steps for logging in Binance PC version: search for "Binance Official Website" in the browser, click the login button, enter the email and password (enable 2FA to enter the verification code) to log in. Secondly, the article explains the registration process: click the "Register" button, fill in the email address, set a strong password, and verify the email address to complete the registration. Finally, the article also emphasizes account security, reminding users to pay attention to the official domain name, network environment, and regularly updating passwords to ensure account security and better use of various functions provided by Binance PC version, such as viewing market conditions, conducting transactions and managing assets.

How to implement cross-application jump for Word plug-in login authorization? When using certain Word plugins, we often encounter this scenario: click on the login in the plugin...

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Experience the convenience of Flutter hot reloading on the Debian system, just follow the steps below: Install FlutterSDK: First, you need to install FlutterSDK on the Debian system. Visit Flutter official website to download the latest stable version of SDK and decompress to the specified directory (for example, ~/flutter). After that, add Flutter's bin directory to the system PATH environment variable. Edit the ~/.bashrc or ~/.profile file, add the following code: exportPATH="$PATH:~/flutter/bin" Save the file and execute source~/.bas

It is not easy to convert XML to PDF directly on your phone, but it can be achieved with the help of cloud services. It is recommended to use a lightweight mobile app to upload XML files and receive generated PDFs, and convert them with cloud APIs. Cloud APIs use serverless computing services, and choosing the right platform is crucial. Complexity, error handling, security, and optimization strategies need to be considered when handling XML parsing and PDF generation. The entire process requires the front-end app and the back-end API to work together, and it requires some understanding of a variety of technologies.
