How does Carbon determine what day of the week it is?

WBOY
Release: 2016-07-06 13:51:50
Original
2975 people have browsed it

Using Carbon in Laravel, how to determine what day of the week today is?

Also,

<code>如何将Carbon::now()得到的结果裁剪成类似这样的格式:20160628;
如何将20160628这样的格式转成Carbon::now()->dayOfYear.
</code>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login

Note: Sunday returns 0

<code>echo (new Carbon('20160628'))->dayOfYear;</code>
Copy after login

Carbon is very flexible. It is recommended to look at the source code. There are many, many methods

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!