search

Home  >  Q&A  >  body text

What is the difference between carbon::now() in the laravel framework and PHP's native time()

Is there a difference between the two or are they equivalent? ?

高洛峰高洛峰2754 days ago520

reply all(4)I'll reply

  • 黄舟

    黄舟2017-05-16 16:55:43

    Carbon是对时间的一个封装。在内部通过使用DateTime实现了很多简单的方法。
    比如Carbon::now来说,使用echo Carbon:now()->toRfc2822String()可以直接获取到当前时间。使用DateTime你可能会需要echo (new DateTime())->format('xxxxx')

    Including other operations on time, increasing and decreasing days/seconds/minutes/months, time comparison, etc.

    This question is equivalent to asking what is the difference between Laravel and PHP (perhaps a little inappropriate). Laravel has encapsulated modules and logical functions such as Route/Request/Http/Command, which can be developed quickly and safely. To develop using pure native PHP, you just need to design various things yourself.

    reply
    0
  • 为情所困

    为情所困2017-05-16 16:55:43

    carbon::now()是基于Datetime’s

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 16:55:43

    You will know soon after taking a look at the static method it encapsulates

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 16:55:43

    No difference, except that it looks taller

    reply
    0
  • Cancelreply