Hi, when i do that:
$dtDate1 = Carbon::create(2016, 1, 1, 0 ,0, 0,'Europe/Paris');
$dtDate2 = Carbon::create(2016, 1, 1, 0 ,0, 0,'Europe/Paris');
$diffHumains = $dtDate2->diffForHumans($dtDate1,true);
$diffHumains returns 1 second...
Appears to be on purpose:
if ($count === 0) {
$count = 1;
}
(https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php#L2399)
The only case in the switch block that can set $count to 0 is the default one. All the other cases skip if the value is not greater than 0. In other words, this will only happen for seconds (the default case).
I am not sure why this would be necessary; "0 seconds ago" is perfectly fine, imo.
I would opt for the facebook wording of "Just now" rather than something as robotic as 0 seconds ago.
+1 form "Just now"
I just into this as well; just now. 馃槣
I would suggest the wording "Same time" when not comparing to now().
It would be a breaking change for everyone that expect to keep having the "1 second" result, and it would mean translate "just now" in 63 languages.
So I recommend to use a custom implementation (extend or macro):
public function customDiffForHumans(self $other = null, $absolute = false, $short = false, $parts = 1)
{
if ($this->diffInSeconds($other, true) < 1) {
return "just now"; // You're on you own for translations
}
return $this->diffForHumans($other, $absolute, $short, $parts);
}
This issue and #625 could be handled in a common way.
The default behavior must keep being what it's now for backward compatibility.
Settings method or options argument (binary values with pipes) could enable the following features:
Will be fixed via #1240
Most helpful comment
I would opt for the facebook wording of "Just now" rather than something as robotic as 0 seconds ago.