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

        <bdo id='tUE23'></bdo><ul id='tUE23'></ul>
      <tfoot id='tUE23'></tfoot>

    1. <i id='tUE23'><tr id='tUE23'><dt id='tUE23'><q id='tUE23'><span id='tUE23'><b id='tUE23'><form id='tUE23'><ins id='tUE23'></ins><ul id='tUE23'></ul><sub id='tUE23'></sub></form><legend id='tUE23'></legend><bdo id='tUE23'><pre id='tUE23'><center id='tUE23'></center></pre></bdo></b><th id='tUE23'></th></span></q></dt></tr></i><div id='tUE23'><tfoot id='tUE23'></tfoot><dl id='tUE23'><fieldset id='tUE23'></fieldset></dl></div>
    2. <legend id='tUE23'><style id='tUE23'><dir id='tUE23'><q id='tUE23'></q></dir></style></legend>
    3. 试图在 PHP 中定义我自己的时间类型

      Trying to define my own time type in PHP(试图在 PHP 中定义我自己的时间类型)
      • <i id='NdeRp'><tr id='NdeRp'><dt id='NdeRp'><q id='NdeRp'><span id='NdeRp'><b id='NdeRp'><form id='NdeRp'><ins id='NdeRp'></ins><ul id='NdeRp'></ul><sub id='NdeRp'></sub></form><legend id='NdeRp'></legend><bdo id='NdeRp'><pre id='NdeRp'><center id='NdeRp'></center></pre></bdo></b><th id='NdeRp'></th></span></q></dt></tr></i><div id='NdeRp'><tfoot id='NdeRp'></tfoot><dl id='NdeRp'><fieldset id='NdeRp'></fieldset></dl></div>
      • <legend id='NdeRp'><style id='NdeRp'><dir id='NdeRp'><q id='NdeRp'></q></dir></style></legend>
      • <tfoot id='NdeRp'></tfoot>
            <tbody id='NdeRp'></tbody>

              <bdo id='NdeRp'></bdo><ul id='NdeRp'></ul>

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

                本文介绍了试图在 PHP 中定义我自己的时间类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                所以我试图定义一个时间类型,但我不太确定如何去做.我在网上找到的答案给出了用当前时间定义时间类型的例子(即 date("h:i:sa"))但是我正在尝试定义一个硬编码版本.我的格式想要的是 (HH:mm:ss) (hour:minutes:seconds) 我需要将变量声明为时间类型的原因是为了以后可以使用它们进行比较.

                So I am trying to define a time type and I am not quite sure how to do it. The answers I find online give examples of defining a time type with the current time (i.e date("h:i:sa")) however I am trying to define a hard coded version.The format I want is (HH:mm:ss) (hour:minutes:seconds) The reason why I need the variable to be declared as time type is so that they can be used later on to be compared.

                <?php 
                $my_time = '10:00:00';
                $your_time = '11:00:00';
                if($my_time > $your_time){
                echo "You have less time";
                }
                ?>
                

                推荐答案

                PHP DateTime 类就是你所需要的.

                The PHP DateTime Class is what you need.

                //instantiate a DateTime Object      
                $time = new DateTime();
                
                //Use the DateTime obj to create two new DateTime objects
                $yourTime = $time->createFromFormat('h:i:s', '12:30:30'); //third param here can define tz
                $theirTime = $time->createFromFormat('h:i:s', '12:10:15');
                
                //Use diff() to return a DateInterval
                $dateInterval = $yourTime->diff($theirTime);
                
                //Format the DateInterval as a string
                $differenceBetweenYoursAndTheirs = $dateInterval->format('%h:%i:%s');
                
                //Do something with your interval
                echo "The difference between {$yourTime->format('h:i:s')} and {$theirTime->format('h:i:s')} is $differenceBetweenYoursAndTheirs";
                

                这篇关于试图在 PHP 中定义我自己的时间类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 的问题)
                  • <bdo id='3oc0p'></bdo><ul id='3oc0p'></ul>
                  • <i id='3oc0p'><tr id='3oc0p'><dt id='3oc0p'><q id='3oc0p'><span id='3oc0p'><b id='3oc0p'><form id='3oc0p'><ins id='3oc0p'></ins><ul id='3oc0p'></ul><sub id='3oc0p'></sub></form><legend id='3oc0p'></legend><bdo id='3oc0p'><pre id='3oc0p'><center id='3oc0p'></center></pre></bdo></b><th id='3oc0p'></th></span></q></dt></tr></i><div id='3oc0p'><tfoot id='3oc0p'></tfoot><dl id='3oc0p'><fieldset id='3oc0p'></fieldset></dl></div>

                      <small id='3oc0p'></small><noframes id='3oc0p'>

                        <legend id='3oc0p'><style id='3oc0p'><dir id='3oc0p'><q id='3oc0p'></q></dir></style></legend>
                        <tfoot id='3oc0p'></tfoot>
                            <tbody id='3oc0p'></tbody>