Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffIn methods return inaccurate results if the difference between datetimes is less than a day #26

Open
toby-dixon opened this issue Dec 13, 2024 · 0 comments

Comments

@toby-dixon
Copy link

a = Carbon() # Create new instance -> now()
b = Carbon() # Create new instance -> now()

b = b.addSeconds(12) # Add seconds to b
print(b.diffInSeconds(a), a.toDateTimeString(), b.toDateTimeString())
# Prints 0 2024-12-13 15:45:41 2024-12-13 15:45:53

b = b.addMinutes(12) # Add seconds to b
print(b.diffInSeconds(a), a.toDateTimeString(), b.toDateTimeString())
# Prints 0 2024-12-13 15:45:41 2024-12-13 15:57:53

b = b.addHours(12) # Add seconds to b
print(b.diffInSeconds(a), a.toDateTimeString(), b.toDateTimeString())
# Prints 0 2024-12-13 15:45:41 2024-12-14 03:57:53

b = b.addDays(12) # Add seconds to b
print(b.diffInSeconds(a), a.toDateTimeString(), b.toDateTimeString())
# Prints 1036800 2024-12-13 15:46:48 2024-12-26 03:59:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant