• <bdo id='mqLp6'></bdo><ul id='mqLp6'></ul>

      <i id='mqLp6'><tr id='mqLp6'><dt id='mqLp6'><q id='mqLp6'><span id='mqLp6'><b id='mqLp6'><form id='mqLp6'><ins id='mqLp6'></ins><ul id='mqLp6'></ul><sub id='mqLp6'></sub></form><legend id='mqLp6'></legend><bdo id='mqLp6'><pre id='mqLp6'><center id='mqLp6'></center></pre></bdo></b><th id='mqLp6'></th></span></q></dt></tr></i><div id='mqLp6'><tfoot id='mqLp6'></tfoot><dl id='mqLp6'><fieldset id='mqLp6'></fieldset></dl></div>

        <tfoot id='mqLp6'></tfoot>

        <legend id='mqLp6'><style id='mqLp6'><dir id='mqLp6'><q id='mqLp6'></q></dir></style></legend>

        <small id='mqLp6'></small><noframes id='mqLp6'>

        MySQL:保持服务器时区或用户时区?

        时间:2024-08-14
      1. <small id='Cec1D'></small><noframes id='Cec1D'>

        1. <i id='Cec1D'><tr id='Cec1D'><dt id='Cec1D'><q id='Cec1D'><span id='Cec1D'><b id='Cec1D'><form id='Cec1D'><ins id='Cec1D'></ins><ul id='Cec1D'></ul><sub id='Cec1D'></sub></form><legend id='Cec1D'></legend><bdo id='Cec1D'><pre id='Cec1D'><center id='Cec1D'></center></pre></bdo></b><th id='Cec1D'></th></span></q></dt></tr></i><div id='Cec1D'><tfoot id='Cec1D'></tfoot><dl id='Cec1D'><fieldset id='Cec1D'></fieldset></dl></div>

          • <legend id='Cec1D'><style id='Cec1D'><dir id='Cec1D'><q id='Cec1D'></q></dir></style></legend>
              <tfoot id='Cec1D'></tfoot>

                  <bdo id='Cec1D'></bdo><ul id='Cec1D'></ul>
                    <tbody id='Cec1D'></tbody>
                  本文介绍了MySQL:保持服务器时区或用户时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在考虑在我的网站中存储用户登录的日期,但我不知道什么是最合乎逻辑的解决方案.

                  I'm thinking about to store dates on user login in my site, but I don't know what is the most logical solution.

                  最初,我想使用服务器时区,然后使用服务器机器日期和用户机器日期之间的差异操作来管理它,但我也考虑过使用时区和 php 类日期直接更改它,所以:

                  Initially, I though to use server timezone, and then to manage it using difference operations between server machine date and user machine date, but I've also considered to change it direclty using timezone and php class date, so:

                  <?php
                  // my server has for example America/New_York timezone
                  $user_timezone = "Europe/Rome";
                  date_default_timezone_set ($user_timezone);
                  $date = date ('Y-m-d H:i:s');
                  $sql = "UPDATE users SET user_last_modify = '$date', user_timezone = '$user_timezone' WHERE user_id = 'some id' LIMIT 1;";
                  $res = mysql_query ($sql);
                  ?>
                  

                  我的问题是,最好的解决方案是保留服务器时区还是使用用户时区?
                  如果我使用用户时区,我是否也应该像我的示例一样保存时区名称?

                  My ask is, what is the best solution, keep server timezone or use user timezone?
                  and if I use user timezone, should I save the timezone name too as in my example?

                  推荐答案

                  我建议使用服务器时区或 UTC,而不是为每个用户存储不同的数据.这样,您的数据库将完全一致,并且您可以执行一些操作,例如比较,而不必为每个条目获取 user_timezone 列并执行转换(这不是完全免费的)

                  I'd recommend using server timezone or UTC, rather than storing different data for each user. This way, your database will be fully consistent, and you can perform some operations like comparisons without having to, for each entry, fetch the user_timezone column and perform the conversion (which is not fully free)

                  这篇关于MySQL:保持服务器时区或用户时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 和 MySQL 的时区问题 下一篇:函数 date_default_timezone_set() 不可用

                  相关文章

                    <bdo id='Cr4P1'></bdo><ul id='Cr4P1'></ul>
                  <tfoot id='Cr4P1'></tfoot>
                • <legend id='Cr4P1'><style id='Cr4P1'><dir id='Cr4P1'><q id='Cr4P1'></q></dir></style></legend>

                  1. <small id='Cr4P1'></small><noframes id='Cr4P1'>

                      <i id='Cr4P1'><tr id='Cr4P1'><dt id='Cr4P1'><q id='Cr4P1'><span id='Cr4P1'><b id='Cr4P1'><form id='Cr4P1'><ins id='Cr4P1'></ins><ul id='Cr4P1'></ul><sub id='Cr4P1'></sub></form><legend id='Cr4P1'></legend><bdo id='Cr4P1'><pre id='Cr4P1'><center id='Cr4P1'></center></pre></bdo></b><th id='Cr4P1'></th></span></q></dt></tr></i><div id='Cr4P1'><tfoot id='Cr4P1'></tfoot><dl id='Cr4P1'><fieldset id='Cr4P1'></fieldset></dl></div>