DateTestTest.php 743 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace OrderCountingRecordService;
  3. use Carbon\Carbon;
  4. use DateInterval;
  5. use DatePeriod;
  6. use DateTime;
  7. use Tests\TestCase;
  8. class DateTestTest extends TestCase
  9. {
  10. /**
  11. * @test
  12. */
  13. public function carbon_date_equals()
  14. {
  15. $this->assertTrue('2020-11-25' == Carbon::now()->format('Y-m-d'));
  16. $this->assertTrue('2020-48' == Carbon::now()->year . '-' . Carbon::now()->week);
  17. $this->assertTrue('2020-11' == Carbon::now()->year . '-' . Carbon::now()->month);
  18. }
  19. /**
  20. * @test
  21. */
  22. public function compare_date()
  23. {
  24. $dateStr = '2020-12-30';
  25. $end = Carbon::parse($dateStr)->gt(Carbon::now()) ? Carbon::now()->toDateString() : $dateStr;
  26. dd($end);
  27. }
  28. }