Answers for "carbon get last 6 months"

PHP
3

laravel carbon get year number

use Carbon\Carbon;
// Date = 7th of July 2021
$year = Carbon::now()->format('Y'); // 2021
$year = Carbon::now()->format('y'); // 21
$year = Carbon::now()->year; // 2021
Posted by: Guest on July-07-2021
-2

carbon last day of month in timestamp

// first day of month (2021-01-01 00:00:00)
Carbon::now()->firstOfMonth()->startOfDay()
 
// first day of month in timestamp (1609459200)
Carbon::now()->firstOfMonth()->startOfDay()->timestamp
 
// last day of month (2021-01-31 23:59:59)
Carbon::now()->lastOfMonth()->endOfDay()
 
// last day of month in timestamp (1640995199)
Carbon::now()->lastOfMonth()->endOfDay()->timestamp
Posted by: Guest on June-17-2021

Code answers related to "carbon get last 6 months"

Browse Popular Code Answers by Language