How does Carbon determine what day of the week it is?
Jul 06, 2016 pm 01:51 PM
Using Carbon in Laravel, how to determine what day of the week today is?
Also,
<code>如何将Carbon::now()得到的结果裁剪成类似这样的格式:20160628; 如何将20160628这样的格式转成Carbon::now()->dayOfYear. </code>
If there is a Chinese document or tutorial on carbon, please give an address. There is too little time and it is too slow to read the official document.
Thank you!
Reply content:
Using Carbon in Laravel, how to determine what day of the week today is?
Also,
<code>如何将Carbon::now()得到的结果裁剪成类似这样的格式:20160628; 如何将20160628这样的格式转成Carbon::now()->dayOfYear. </code>
If there is a Chinese document or tutorial on carbon, please give an address. There is too little time and it is too slow to read the official document.
Thank you!
Using PHP native method.
carbon is an external dependency package, you can take a look at this http://carbon.nesbot.com/docs/
<code>$dt = Carbon::now()->dayOfWeek; // $dt = 0 ~ 6</code>
Note: Sunday returns 0
<code>echo (new Carbon('20160628'))->dayOfYear;</code>
Carbon
is very flexible. It is recommended to look at the source code. There are many, many methods

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
