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
-2
votes
1 answer

Carbon::now returns wrong month

I'm trying to make cron job for my system. The project is configured for time zone that differs from mine I tried $timezone = date_default_timezone_get(); $current = Carbon::now(new \DateTimeZone($timezone)); It returns 2018-01-05 06:36:15 which…
Sara Shokry
  • 26
  • 1
  • 9
-2
votes
1 answer

How to solve Carbon diffForHumans() time mismatch?

I use Laravel 5.3 for news create duration in Lravel blade tempate i use echo \Carbon\Carbon::createFromTimeStamp(strtotime($news->approved_at),'Asia/Dhaka')->diffForHumans() but i get time mismatch. suppose approved_at = 2017-05-21…
Masum billah
  • 982
  • 7
  • 24
-2
votes
1 answer

PHP DateTime format Year bug

this is the first time i encountered this bug, i usually use the same syntax to format dates. but now, i don't know what happened to DateTime format. I've tried searching some resources, including Carbon and php DateTime formatting. but no luck. PS:…
Hitori
  • 569
  • 1
  • 5
  • 21
-2
votes
1 answer

Time Difference in Two Formats

I have two time values that I want to take difference of. First is coming from a database, and it looks like "2014-05-13 10:41:09". It's in "Y-m-d H:i:s" format. But it's a Carbon object. I have another time, which is now. I get it like date('Y-m-d…
-3
votes
1 answer

Best Practice in Carbon format in laravel

What is the difference between Carbon::format('Y-m-d h:i:s') and Carbon::format('Y-m-d H:i:s') in format?
-3
votes
1 answer

How to convert UTC date to datetime type Laravel?

I have UTC time as: 2021-01-30T21:00:00.000Z How to convert it to datetime type for adding to database using Carbon? I have tried this: Carbon::now(new Date("2021-01-30T21:00:00.000Z"))->format("yyyy-dd-mm");
user14897345
-3
votes
1 answer

How to get start date by month number?

I have a number of month in range 1-12 How to get start and end of date by month number like this: 2018-01-01 - 2018-31-01
Karabah
  • 229
  • 1
  • 4
  • 12
-3
votes
1 answer

How to get carbon current time with X minute leap?

E.G. If I want current date with 15 minute leap: If now is : 2017-2-2 18:22 15 minute leap time will be : 2017-2-2 18:30 If now is : 2017-2-2 18:30 15 minute leap time will be : 2017-2-2 18:30 If now is : 2017-2-2 18:31 15 minute leap time will…
fico7489
  • 7,931
  • 7
  • 55
  • 89
-3
votes
1 answer

How to set print format on Carbon object ? not globaly

I have code like: $value = \Carbon\Carbon::createFromFormat('Y-m-d', $value)->format('m/d/Y'); and function format return string, I want to set format but return Carbon object, something like: $value = \Carbon\Carbon::createFromFormat('Y-m-d',…
fico7489
  • 7,931
  • 7
  • 55
  • 89
-3
votes
2 answers

correctly adding and substracting date?

Lets take any month be of 30 days, then for the date 25/02/2015 when we add 10 days it becomes 5/03/2015 but there are months which are of 29 and 31 days as well.If a month be of 31 then adding 10 days to 25/04/2015 would be 04/05/2015 not…
Sumit
  • 1,235
  • 4
  • 17
  • 29
-4
votes
2 answers

Check if one date is after another?

I am trying to check if one datetime is after another, but it doesn't seem to be working. I am simply using the >= operator, but it is not working as expected? Here is the code: public function hasCompleted() { return…
AAA
  • 361
  • 1
  • 5
  • 19
1 2 3
96
97