Skip to content

Commit d4ce7e2

Browse files
Documentation - Fix Time Library - Fit Sampe for TimeDifference humanize() method
Signed-off-by: Najdanovic Ivan <najdanovicivan@gmail.com>
1 parent 92c5555 commit d4ce7e2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

user_guide_src/source/libraries/time.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,12 @@ Much like Time's humanize() method, this returns a string that displays the diff
498498
human readable format that is geared towards being easily understood. It can create strings like '3 hours ago',
499499
'in 1 month', etc. The biggest differences are in how very recent dates are handled::
500500

501-
// Assume current time is: March 10, 2017 (America/Chicago)
502-
$time = Time::parse('March 9, 2016 12:00:00', 'America/Chicago');
501+
$current = Time::parse('March 10, 2017', 'America/Chicago')
502+
$test = Time::parse('March 9, 2016 12:00:00', 'America/Chicago');
503503

504-
echo $time->humanize(); // 1 year ago
504+
$diff = $current->difference($test)
505+
506+
echo $diff->humanize(); // 1 year ago
505507

506508
The exact time displayed is determined in the following manner:
507509

0 commit comments

Comments
 (0)