Home Backend Development PHP Tutorial The time of php time() and date() is different from that of the local computer_PHP tutorial

The time of php time() and date() is different from that of the local computer_PHP tutorial

Jul 13, 2016 am 10:43 AM
date php time and Why classmate time There is a difference local computer

My classmates often ask me why the time of php time() and date() is different from that of the local computer. How many hours are there? If you calculate it carefully, there is a difference of 8 hours. This is a problem with the time zone setting of php date_default_timezone_set , we just need to set it up simply.

The time of php time() and date() is different from that of the local computer_PHP tutorial

If the date time is inconsistent, you can use date_default_timezone_set to set the time zone:

The code is as follows
 代码如下 复制代码
";   //对当前时间进行计算 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 "
";  

?>

Copy code

"; ​ //Calculate the current time echo date('Y-m-d H:i:s',time()-600); //Subtract 10 hours echo "
"; ​ //Timestamp to time echo date('Y-m-d H:i:s',1364277600); ​ //Convert time to timestamp (accurate to seconds only) echo strtotime("2013-03-26 14:00"); echo "
"; ​
 代码如下 复制代码

date.timezone = PRC

?>

In addition to the above method, we can also set a time zone in php.ini, so that in the future there will be no need to add date_default_timezone_set('Asia/Chongqing'); in the program

The code is as follows Copy code
date.timezone = PRC http://www.bkjia.com/PHPjc/633191.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633191.htmlTechArticleSome students often ask me why php time() and date() time are different from the local computer, related How many hours are there? If you calculate carefully, there is a difference of 8 hours. This is php date_default_tim...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Why is the rise or fall of virtual currency prices? Apr 21, 2025 am 08:57 AM

Factors of rising virtual currency prices include: 1. Increased market demand, 2. Decreased supply, 3. Stimulated positive news, 4. Optimistic market sentiment, 5. Macroeconomic environment; Decline factors include: 1. Decreased market demand, 2. Increased supply, 3. Strike of negative news, 4. Pessimistic market sentiment, 5. Macroeconomic environment.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Recently, cryptocurrency markets have been facing turmoil, and Cardano (ADA) has dropped below key support levels amid economic uncertainty. Recently, cryptocurrency markets have been facing turmoil, and Cardano (ADA) has dropped below key support levels amid economic uncertainty. Apr 21, 2025 pm 02:33 PM

Cryptocurrency market turmoil has intensified, and Cardano (ADA) has fallen below key support levels, raising concerns among investors. This article will analyze the recent performance of ADA and compare the strong growth momentum of another cryptocurrency, Coldware (COLD). ADA prices have continued to decline in the past five months, falling below the $0.61 support level on April 7, 2025, triggering volatility in the overall cryptocurrency market. At the same time, Coldware (COLD)'s pre-sale performed well, with financing of US$2.4 million in the second phase. So, what are the advantages of Coldware compared to Cardano? Coldware rises against the trend. In the same market environment where ADA prices fall, Coldware(C

Why should you listen Why should you listen Apr 21, 2025 pm 09:00 PM

Concordium: A public first-level blockchain platform that takes into account privacy and compliance is a public first-level blockchain platform. Its core lies in the clever integration of identity verification with privacy and regulatory compliance. Founded in 2018 by Lars Seier Christensen, the platform’s core technology embeds cryptographic identities at the protocol level of each transaction. This unique design ensures responsibility traceability while protecting user privacy, effectively solving the problem of conflicts between anonymity and regulatory requirements in the blockchain field. To alleviate this problem, Concordium utilizes Zero Knowledge Proof (ZKP) technology, allowing users to verify specific identity attributes without the need to disclose unnecessary personal information. This means that, despite every

Understand one article: Binance KERNEL Airdrop Process Understand one article: Binance KERNEL Airdrop Process Apr 21, 2025 pm 01:09 PM

In the world of cryptocurrencies, new opportunities always emerge. Recently, the KernelDAO (KERNEL) Megadrop project launched by Binance has attracted widespread attention. This project not only brings new investment options to investors, but also provides unique benefits to BNB holders. So, what exactly is KernelDAO? How will this airdrop be carried out? Let us understand it in one article.

Binance download link Binance download path Binance download link Binance download path Apr 24, 2025 pm 02:12 PM

To safely download the Binance APP, you need to go through the official channels: 1. Visit the Binance official website, 2. Find and click the APP download portal, 3. Choose to scan the QR code, app store, or directly download the APK file to download to ensure that the link and developer information are authentic, and enable two-factor verification to protect the security of the account.

How to display today's date in WordPress (2 easy ways) How to display today's date in WordPress (2 easy ways) Apr 20, 2025 am 07:27 AM

Do you want to display today's date in WordPress? Many news websites, online journals, and frequently updated blogs may want to show the current date and time. This allows users to know the current date and when the content was published. In this article, we will show you how to easily display today's date or current time on your WordPress site. Why show today's date in WordPress? Many news sites display current dates in the title section of their website, especially small news sites that publish their main stories every day. This assures the user that they are viewing the latest version of the online version of the publication

How to download OK Exchange? The official latest version of the OK Exchange APP download tutorial How to download OK Exchange? The official latest version of the OK Exchange APP download tutorial Apr 21, 2025 pm 12:51 PM

OK Exchange is a world-renowned digital asset trading platform that is trusted by users. It provides a variety of digital currency trading services, supports a variety of fiat currency trading pairs, and meets the trading needs of different users. OK Exchange's APP has powerful functions, a friendly interface, supports multiple languages, and is convenient for users around the world. In order to enable everyone to quickly and safely download and install the OK Exchange APP, this article will provide you with detailed download and installation tutorials.

See all articles