<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 格式转换为纪元

        mm/dd/yyyy format to epoch with PHP(使用 PHP 将 mm/dd/yyyy 格式转换为纪元)

        <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 格式转换为纪元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                • <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>
                          <tbody id='UevHf'></tbody>
                        <legend id='UevHf'><style id='UevHf'><dir id='UevHf'><q id='UevHf'></q></dir></style></legend>