briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.53k stars 1.28k forks source link

Error addRealSeconds #2968

Closed ArtyshkoAndrey closed 6 months ago

ArtyshkoAndrey commented 6 months ago

Hello, pls fixx >addRealSeconds method

I encountered an issue with the following code:

echo Carbon\Carbon::now()->addRealSeconds(90)->getTimestamp();;

Carbon version: 3.1.1 PHP version: 8.3

image

I expected to get:

Thanks!

kylekatarnls commented 6 months ago

Hello,

I can't reproduce here, it does not fail neither in unit tests.

Do you reproduce if you create a file with only this:

<?php

require __DIR__ . '/vendor/autoload.php';

echo \Carbon\Carbon::now()->addRealSeconds(90)->getTimestamp();

And no code executed before? I suspect you might have something such as Carbon::setTestNow('1970-01-01 00:0 UTC') in such case, then 90 would be the expected output.

ArtyshkoAndrey commented 6 months ago

But in version 3.0 methods has work correct. Sorry my English. In version 3.0 method return real timestamp, but 3.1 return int or string non-timestamp

ArtyshkoAndrey commented 6 months ago

After run addRealSeconds, timestamp not correct

ArtyshkoAndrey commented 6 months ago

Sorry. True, in version 3.1 and higher the script works correctly. Apparently there are problems in Laravel ^11.0