为什么date得到时间跟机器时间不一样?
我想用date()得到当前的时间跟数据库里面某个datetime类型的值进行比较。我用echo date('Y-m-d h:m:s')得到是2012-04-04 07:04:20
但是现在我的机器时间是2012-04-04 19:47:20,不知道为什么不一样?
我怎么比较两个时间,是不是需要转换成秒才能比较呢?
我查看php.ini中时间有关的设置如下:
; Default timestamp format.
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
; Default date format.
ibase.dateformat = "%Y-%m-%d"
; Default time format.
ibase.timeformat = "%H:%M:%S"
------解决方案--------------------
楼主用的是美国服务器?时区不一样吧
------解决方案--------------------
时区问题,修改php.ini date.timezone = "Asia/Shanghai"
------解决方案--------------------
除了设置时区,差8小时 分钟可不是m哦
echo date('Y-m-d h:m:s')
echo date('Y-m-d H:i:s')
翻手册去
------解决方案--------------------
注意 H h的区别
还有 m i 手册是最好的
------解决方案--------------------
- PHP code
date_default_timezone_set('PRC');<br><font color="#e78608">------解决方案--------------------</font><br>抱歉,没仔细看马马虎虎就回答了。#4的答案才是正确的<br>至于比较,在mysql 里 datetime类型是可以用比较字符串的方式比较的<br>例如 where '2012-3-3 13:34:34' > `time`<br>取出所有2012-3-3 13:34:34之前的列<div class="clear"> </div>

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

Autoloading in PHP automatically loads class files when needed, improving performance by reducing memory use and enhancing code organization. Best practices include using PSR-4 and organizing code effectively.

PHP streams unify handling of resources like files, network sockets, and compression formats via a consistent API, abstracting complexity and enhancing code flexibility and efficiency.

The article discusses managing file upload sizes in PHP, focusing on the default limit of 2MB and how to increase it by modifying php.ini settings.

The article discusses nullable types in PHP, introduced in PHP 7.1, allowing variables or parameters to be either a specified type or null. It highlights benefits like improved readability, type safety, and explicit intent, and explains how to declar

The article discusses the differences between unset() and unlink() functions in programming, focusing on their purposes and use cases. Unset() removes variables from memory, while unlink() deletes files from the filesystem. Both are crucial for effec


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

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

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
