【问题标题】:How do you find a description of the DateTime class in the PHP documentation?如何在 PHP 文档中找到 DateTime 类的描述?
【发布时间】:2008-11-25 06:49:15
【问题描述】:

听起来很简单,但我在文档中找不到这个内置类和其他类的位置。我使用函数,但想知道 OO 方面有什么。

【问题讨论】:

    标签: php datetime


    【解决方案1】:

    它不是 URL 或任何东西,但您可以使用反射获得一个公平的想法:

    Reflection::export(new ReflectionClass('DateTime'));
    
    Class [  class DateTime ] {
    
      - Constants [11] {
        Constant [ string ATOM ] { Y-m-d\TH:i:sP }
        Constant [ string COOKIE ] { l, d-M-y H:i:s T }
        Constant [ string ISO8601 ] { Y-m-d\TH:i:sO }
        Constant [ string RFC822 ] { D, d M y H:i:s O }
        Constant [ string RFC850 ] { l, d-M-y H:i:s T }
        Constant [ string RFC1036 ] { D, d M y H:i:s O }
        Constant [ string RFC1123 ] { D, d M Y H:i:s O }
        Constant [ string RFC2822 ] { D, d M Y H:i:s O }
        Constant [ string RFC3339 ] { Y-m-d\TH:i:sP }
        Constant [ string RSS ] { D, d M Y H:i:s O }
        Constant [ string W3C ] { Y-m-d\TH:i:sP }
      }
    
      - Static properties [0] {
      }
    
      - Static methods [0] {
      }
    
      - Properties [0] {
      }
    
      - Methods [9] {
        Method [  public method __construct ] {
        }
    
        Method [  public method format ] {
        }
    
        Method [  public method modify ] {
        }
    
        Method [  public method getTimezone ] {
        }
    
        Method [  public method setTimezone ] {
        }
    
        Method [  public method getOffset ] {
        }
    
        Method [  public method setTime ] {
        }
    
        Method [  public method setDate ] {
        }
    
        Method [  public method setISODate ] {
        }
      }
    }
    

    不完美,因为没有论据,但至少是一个起点。他们应该让这更容易被发现,我同意!

    【讨论】:

    • 当时我特别感兴趣的是构造函数,而反射没有给出。我是反射类的新手,可能会使用一段时间(我想知道它是否容易在 PHP 文档中找到?)
    • :) au.php.net/oop5.reflection 如果特别是构造函数,这可能会有所帮助: format(DATE_ATOM); ?>(来自 date_create() 手册页)。
    【解决方案2】:

    http://no2.php.net/date_create

    构造函数信息。一些关于 cmets 序列化的好信息。

    http://laughingmeme.org/2007/02/27/ 不错的教程,可能有点老了。

    http://ditio.net/2008/06/03/php-datetime-and-datetimezone-tutorial/ 另一个略有不同的方法教程。

    【讨论】:

      【解决方案3】:

      您提到的 URL http://www.php.net/manual/en/migration52.classes.php 根本没有描述该类。当然,在某个地方记录了此类和其他类。

      【讨论】:

        【解决方案4】:

        这里有一个 PHP 5.2.0 中的新类列表:

        http://www.php.net/manual/en/migration52.classes.php

        ..这里链接到新的 DateTime 类信息:

        http://www.php.net/manual/en/ref.datetime.php

        【讨论】:

          【解决方案5】:

          可以在文档的 cmets 中找到描述:

          http://php.net/manual/fr/book.datetime.php#84699

          编辑:今天早上我发现了一些有趣的东西:

          http://laughingmeme.org/2007/02/27/looking-at-php5s-datetime-and-datetimezone/

          【讨论】:

          • 但是这些类不应该记录在某个地方吗?我不能依赖贡献的笔记,而且无论如何它们都没有提供完整的文档。
          • 确实如此。 PHP 5 中没有记录很多东西,这就是问题所在。 PHP 建立了它的代表部分是因为它的优秀文档弥补了语言的“混乱”。现在语言变得整洁,文档不完整。这背后有规律吗?我添加了一个指向我的答案的链接...
          【解决方案6】:

          可以在 php.net/DateTime 找到 DateTime 类文档,其中包含有关类和函数的信息,或者仅在 php.net/manual/en/class.datetime.php 中提供类文档

          【讨论】:

            【解决方案7】:

            这些东西记录在文档中 - 也许不是你要求的时候。

            无论如何,通过扩展的作者,您可以阅读以获取完整的详细信息:http://derickrethans.nl/phparchitects-guide-to-date-and-time-programming.html

            旁边是 Derick Rethans 就该主题到处发表演讲,并提供幻灯片。如果您有机会参加会议并聆听他的演讲,那就去做吧。

            最近的一个:

            FrOsCon,2010 年 8 月 22 日:xxxx://derickrethans.nl/talks/time-froscon10.pdf(来源:xxxx://derickrethans.nl/talks.html)

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 2012-12-28
              • 1970-01-01
              • 2011-07-24
              • 2013-07-19
              • 2016-06-18
              • 2018-01-27
              • 2020-06-24
              相关资源
              最近更新 更多