I'm encountering two peculiar behaviors with a library, and my objective is to convert seconds into a readable format displaying days, hours, minutes, and seconds.
When attempting to convert 2698447 seconds into a human-readable format using the Carbon library, I obtain the following result:
<?php
use Carbon\CarbonInterval;
use Carbon\Carbon;
echo CarbonInterval::seconds(2698447)->cascade()->forHumans();
In my code, I also experimented with CarbonInterval, and when converting 28 days and 30 days separately, the output seems to imply that 28 days is equivalent to a month:
use Carbon\CarbonInterval;
use Carbon\Carbon;
echo CarbonInterval::seconds(28*24*3600)->cascade()->forHumans(); // Outputs: 28 days
echo "\n";
echo CarbonInterval::seconds(30*24*3600)->cascade()->forHumans(); // Outputs: 30 days
echo "\n";
When attempting to convert 2698447 seconds into a human-readable format using the Carbon library, I obtain the following result:
<?php
use Carbon\CarbonInterval;
use Carbon\Carbon;
echo CarbonInterval::seconds(2698447)->cascade()->forHumans();
In my code, I also experimented with CarbonInterval, and when converting 28 days and 30 days separately, the output seems to imply that 28 days is equivalent to a month:
use Carbon\CarbonInterval;
use Carbon\Carbon;
echo CarbonInterval::seconds(28*24*3600)->cascade()->forHumans(); // Outputs: 28 days
echo "\n";
echo CarbonInterval::seconds(30*24*3600)->cascade()->forHumans(); // Outputs: 30 days
echo "\n";