php - MySQL时间和PHP时间相差35秒
问题描述
MySQL:
exec("SET time_zone='+05:30';");
now();
PHP:
date_default_timezone_set("Asia/Kolkata");
echo $current_time = date('Y-m-d H:i:s ', time());
MySQL 将正确的时间设置为 IST,但 PHP 显示的时间比 IST 晚 35 秒。为什么这样?
解决方案
您确定要同时执行这两个代码吗?有两种可能: 1. 执行时间不同。2. php.ini 文件中定义的 date_default_timezone_set() 错误。
推荐阅读
- aws-amplify - AWS Amplify Storage:在存储中未找到提供商的插件
- javascript - ReactJS - 是什么让 bundle.js 变大
- android - 如何在 android studio 模拟器中修复此错误?
- asp.net - 如何从现有镜像构建 Docker 容器
- java - 如何修复 Apache Beam 中的“加入无界 PCollections 目前仅支持带有触发器的非全局窗口”
- django - 基于类视图的Loggin django没有工作,
- javascript - Javascript:访问具有相同名称的 JSON 属性?
- vuejs2 - 我可以使用 vue2 beforeCreate 访问什么?
- python - 用于有向图的 Python igraph 密度函数
- java - 为什么我的代码没有返回我想要它做的事情?