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

  • <small id='cUXzs'></small><noframes id='cUXzs'>

    1. <tfoot id='cUXzs'></tfoot>
      <legend id='cUXzs'><style id='cUXzs'><dir id='cUXzs'><q id='cUXzs'></q></dir></style></legend>
        <bdo id='cUXzs'></bdo><ul id='cUXzs'></ul>

      1. 使用 PHP 将 mm/dd/yyyy 格式转换为纪元

        时间:2024-04-12

        <legend id='umfzv'><style id='umfzv'><dir id='umfzv'><q id='umfzv'></q></dir></style></legend>
      2. <i id='umfzv'><tr id='umfzv'><dt id='umfzv'><q id='umfzv'><span id='umfzv'><b id='umfzv'><form id='umfzv'><ins id='umfzv'></ins><ul id='umfzv'></ul><sub id='umfzv'></sub></form><legend id='umfzv'></legend><bdo id='umfzv'><pre id='umfzv'><center id='umfzv'></center></pre></bdo></b><th id='umfzv'></th></span></q></dt></tr></i><div id='umfzv'><tfoot id='umfzv'></tfoot><dl id='umfzv'><fieldset id='umfzv'></fieldset></dl></div>
          <bdo id='umfzv'></bdo><ul id='umfzv'></ul>
            1. <small id='umfzv'></small><noframes id='umfzv'>

              1. <tfoot id='umfzv'></tfoot>

                  <tbody id='umfzv'></tbody>

                  本文介绍了使用 PHP 将 mm/dd/yyyy 格式转换为纪元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 mysql 表,它依赖于相当于条目日期的 unix 纪元时间戳在网站的各个部分进行排序和过滤.我正在尝试实现一个日期选择器,它将日期以 mm/dd/yyyy 格式输入到表单字段中.我一直在努力将该日期转换为 unix 纪元格式以将该条目添加到行字段中.我所做的所有尝试都导致生成当天的纪元时间戳.有谁知道我如何采用该日期格式并将其转换为等效的纪元时间戳?

                  I have a mysql table that relies on the unix epoch time stamp equivalent of the date of the entry to sort and filter in various parts of the website. I'm trying to implement a date picker that will enter the date into the form field in the mm/dd/yyyy format. I've been struggling with converting that date into the unix epoch format to add that entry in the row field. All the attempts I've made have resulted in generating the current day epoch time stamp. Does anyone have any idea how I can take that date format and convert in the it's equivalent epoch time stamp?

                  提前致谢.

                  其他信息:

                  我一直在尝试 mktime,我得到的只是今天的时代.抱歉,我应该早点添加一些代码来更好地解释:

                  I have been trying mktime, and all I get is todays epoch. Apologies, I should have added some code earlier to better explain:

                  表单id是date",数据库字段是epoch"

                  The form id is "date" The database field is "epoch"

                  这是我在发布 for 日期时正在尝试的(未成功):

                  Here's what I'm trying (unsuccessfully) when I post the for date:

                  $epochhold = ($_POST['date']);
                  $epoch = mktime(0,0,0,$epochhold);
                  

                  我从之前的帖子中了解到,这仍然会将值提交为 mm/dd/yyyy,而不是 mktime 期望的 mm、dd、yyyy,但是该帖子没有提供有关如何执行此操作的解决方案.我尝试使用 str_replace 将/"更改为",结果相同 - 无论输入的日期如何,都获取今天的纪元日期.

                  I understand from a previous post that this would still submit the value as mm/dd/yyyy and not mm, dd, yyyy as mktime expects, however the post didn't offer and resolution on how to do that. I tried a str_replace to change the "/" to "," and that yeilded the same result - getting today's epoch date regardless of the date entered.

                  这是那个代码示例 - 这同样不起作用,但我添加它以帮助说明我尝试过的内容

                  Here's that code example - again this didn't work, but I add it to help illustrate what I've tried

                  $epochhold = ($_POST['date']);
                  $epochold2 = str_replace('/', ', ', $epochhold)
                  $epoch = mktime(0,0,0,$epochhold2);
                  

                  也感谢之前的回复,我不希望快速回复被忽视!

                  Thanks for the previous response as well, I didn't want the quick reply to go unnoticed!

                  谢谢大家!

                  感谢大家的回复 - strtotime 似乎在初始测试中工作得最好,并且可能是要走的路,因为这种格式在整个网站上都是一致的.但是所有的建议都对其他一些事情有所帮助,所以再次感谢大家!

                  Thanks to everyone for the replies - strtotime seems to be working best on the initial tests and may be the way to go as this format is consistent throughout the site. But all the suggestions helped with this a few other things all well so thank you all again!

                  推荐答案

                  如果你知道它永远是那个格式,strtotime 会直接把它转换成unix时间戳.

                  If you know that it will always be in that format, strtotime will convert it directly into the unix timestamp.

                  strtotime($_POST['app_date']);
                  

                  HTH!

                  这篇关于使用 PHP 将 mm/dd/yyyy 格式转换为纪元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么我的 time() 在 php 中减少了一小时? 下一篇:PHP - 从时差中排除所有非营业时间/天

                  相关文章

                • <small id='UevHf'></small><noframes id='UevHf'>

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

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