php-carbon
Laravel Carbon, retrieve today’s date with weekday?
I’m not sure that Carbon has such formatting, but what you could do is get the wekkday from a map of days and the current week day constant: $weekMap = [ 0 => ‘SU’, 1 => ‘MO’, 2 => ‘TU’, 3 => ‘WE’, 4 => ‘TH’, 5 => ‘FR’, 6 => ‘SA’, ]; $dayOfTheWeek = … Read more
Carbon – get first day of month
You can use following function $start = Carbon::now()->startOfMonth(); $end = Carbon::now();
Convert Unix Timestamp to Carbon Object
Did you check the carbon docs? I think this is what youre looking for: Carbon::createFromTimestamp(-1)->toDateTimeString(); Checkout http://carbon.nesbot.com/docs/#api-instantiation
Laravel Carbon See if date is in the past
There’s built-in Carbon method isPast so you can use: $league->date_start->isPast() to determine if date is in past or not
Format Timezone for Carbon Date
You can change the timezone with this: $timestamp = ‘2014-02-06 16:34:00’; $date = Carbon::createFromFormat(‘Y-m-d H:i:s’, $timestamp, ‘Europe/Stockholm’); $date->setTimezone(‘UTC’); this format working fine to my Local(Ubuntu) and prod(Redhat) project.
PHP Carbon class changing my original variable value
When you run these methods against a Carbon object it updates the object itself. Therefore addDay() moves the value of Carbon one day forward. Here’s what you need to do: $now = Carbon::now(); $now->copy()->addDay(); $now->copy()->addMonth(); $now->copy()->addYear(); // etc… The copy method essentially creates a new Carbon object which you can then apply the changes to … Read more