Questions tagged [php-carbon]

Carbon is a library written in PHP that extends the native DateTime class

Carbon is a simple API extension for DateTime for PHP/5.3+. The Carbon class is inherited from the PHP DateTime class. You can find more about Carbon in Carbon Docs

1451 questions
-1
votes
1 answer

Trying to get property of non-object (using Carbon in Laravel 5.3)

I got this query $paid_at = $invoice->payments->last()->paid_at which works just fine, returning a string with a date "2013-04-04" (dd, var_dump, print_r confirmed it). But when I feed it to Carbon $paid = new Carbon($paid_at);I suddenly get this…
Vitalij
  • 658
  • 8
  • 22
-1
votes
2 answers

How to calculate the time difference in Laravel

How to get the remaining time up to the date of consumption .. {{$item->created_at->toDateString()->diffInDays($item->expired)}} {{$item->created_at->toDateString() - $item->expired}}
Morteza Negahi
  • 3,305
  • 8
  • 24
  • 42
-1
votes
1 answer

Complex time interval check in PHP

I have a complex time interval check I'm struggling to solve. Here is the problem: I need to dynamically calculate pick up time for orders. Orders from Monday 10:01am till Wednesday 10am will be delivered on Friday. Orders from Wednesday 10:01 till…
RiaanZA
  • 158
  • 1
  • 9
-1
votes
2 answers

List start & end date of each week in a year dynamically

How can i get list of all Weeks in a Year and each weeks Start and End date dynamically ? Each week Day should start from Monday Thanks in advance :)
Jay
  • 3,353
  • 5
  • 25
  • 34
-1
votes
1 answer

get records from database base on the specified date range laravel 5

How can I retrieved records from the database using carbon dates with the specified date range e.g retrieved records from "2014-10-13" to "2015-11-18"? any ideas, help, suggestions, clues, recommendations please?
Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
-1
votes
2 answers

How can I format separate date and time variables in Laravel

I have a $date and $time fields that are stored in my db, I would like to know how can I format these fields to display them in a different format? e.g. 2010-05-09 -> 9th May 2010 and 13:00:00 -> 1:00PM I have tried to use carbon but it returns…
InvalidSyntax
  • 9,131
  • 20
  • 80
  • 127
-1
votes
1 answer

How to convert week-days into hours in laravel 4.2?

1-If any user enter 1w2d in input field. 2-Value in this input field should get converted to total hours. 3After that I have to insert these total hours in database. 4When I will fetch total hours from database it should return 1w2d. Possible…
Himanshu Dwivedi
  • 107
  • 1
  • 2
  • 10
-1
votes
1 answer

How do I find how many days are within a date range that are within another date range in PHP?

I'm using Carbon PHP library.The answer in the duplicate question uses PHP's built in function. count how many days within a date range are within another date range Below is the code that I use to find if a date range($userDateStart and…
user3407278
  • 1,233
  • 5
  • 16
  • 32
-2
votes
1 answer

How do I convert `June, 18 2021 21:33` to `2021-06-18 21:33:00` in PHP?

This is simple to some; I got the time: June, 18 2021 21:33 How do I convert into 2021-06-18 21:33:00 in PHP. I tried: $send_time = "June, 18 2021 21:33"; $date = Carbon::parse($send_time); echo $date->format('Y-m-d h:i:sa'); Then got Could…
Qwerty
  • 33
  • 6
-2
votes
2 answers

cant parse DateTime::__construct()

I have a @foreach on my blade: @foreach {{ $value-> StartDate}} @endforeach the StartDate is currently displaying like 'sept 2020 12:00:00AM' I want it do be formatted as 'dd/mm/yy'/'d/m/y' essentially like 23-09-2020 or 23/09/2020 I have tried {{…
-2
votes
1 answer

Bulk MySQL update instead of PHP While loop

I am using PHP code to update week ending date which is on a different day for each subdomain. Each subdomain date range varies. My current code uses a while loop to update the week end date. This is very slow and I am looking for ideas to…
Adam
  • 473
  • 5
  • 21
-2
votes
1 answer

Server Hour considering another TZ as reference

I am trying to trigger a worker at certain hour. The thing is that I need to know what is the relative hour of the server for that hour. Clients want to trigger the worker at 8pm everyday in Los Angeles Time, so I have to make it the enough dynamic…
Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115
-2
votes
3 answers

PHP get closest time to given array of times

I have an array called $timeslots with timeslots like: array:32 [▼ 0 => "2018-12-15T12:00:00.0000000" 1 => "2018-12-15T12:15:00.0000000" 2 => "2018-12-15T12:30:00.0000000" 3 => "2018-12-15T12:45:00.0000000" 4 =>…
Aleks Per
  • 1,549
  • 7
  • 33
  • 68
-2
votes
1 answer

How to make list of 1st and last day of month using only DateTime?

I want to make array of previous month 1st and last day. From my starting \DateTime $date=2018-04-30. When I change my starting \DateTime to 2018-05-31 and my expected result is an array that contains: [ ['2018-03-01', 2018-03-31], …
Aipo
  • 1,805
  • 3
  • 23
  • 48
-2
votes
1 answer

Make interval of time laravel

i have 2 time: start time is 10.00 and end time is 12.00 . So i want to make like this : 10.15 10.30 10.45 until 12.00. The interval of this time is 12. So how can i to make the interval of the…
1 2 3
96
97