How does Carbon determine the day of the week?

Source: Internet
Author: User
How can I determine the day of the week when I use Carbon in Laravel? In addition, if {code...} has a Chinese document or tutorial of carbon, please give an address. The time is too small and it is too slow to read official documents. Thank you! How can I determine the day of the week when I use Carbon in Laravel?

In addition,

How to crop the results of Carbon: now () to a format like this: 20160628; how to convert a format like 20160628 to Carbon: now ()-> dayOfYear.

If you have a Chinese document or tutorial for carbon, please give it an address. it takes too little time to read official documents.

Thank you!

Reply content:

How can I determine the day of the week when I use Carbon in Laravel?

In addition,

How to crop the results of Carbon: now () to a format like this: 20160628; how to convert a format like 20160628 to Carbon: now ()-> dayOfYear.

If you have a Chinese document or tutorial for carbon, please give it an address. it takes too little time to read official documents.

Thank you!

The native PHP method is used.

Carbon is an external dependency package, you can take a look at this http://carbon.nesbot.com/docs/

$dt = Carbon::now()->dayOfWeek;// $dt = 0 ~ 6

Note: 0 is returned on Sunday.

echo (new Carbon('20160628'))->dayOfYear;

CarbonIt is very flexible. it is recommended to look at the source code in many ways

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.