Closed pdscopes closed 4 years ago
Hello,
Those intervals are actually translated into hundred different languages according to ->locale()
setting.
In this array unit and unitShort are in fact the key for translations you would find in the Lang directory such as randomly chinese: https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Lang/zh_Hans.php#L39
So a consistent change would also require to translate "ms" and millisecond" in every languages and for sure adding an option, 99% of the time diffForHumans()
is used to show the age of a message/article or the remaining time before an event, and millisecond is nearly never relevant for those cases.
I'm open to pull-request for this feature.
Note: you could create the CarbonInterval
directly rather than using Carbon
and timestamps:
echo CarbonInterval::fromString('1.114 seconds')
->cascade()
->forHumans(Carbon::DIFF_ABSOLUTE, true, 2);
Great, thanks for the direct way of doing it.
I'll work on a pull request tomorrow. Not sure I'll be able to do all languages 100% accurately. I am going to keep it backwards compatible so the default smallest unit will be seconds.
Hello,
I encountered the following "issue" with the following code:
Carbon version: 2.30.0
PHP version: 7.3.15
I want to get:
But I actually get:
Thanks!
I have worked out a naive solution however this is not backwards compatible and I think it'd be a useful thing to be able to specify (maybe in the options) the smallest unit allowed: