# Preparation
1. Open `core/units/users/users_config.php` for editing and change line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:1', 'default' => '#NOW#'),
```
# Testing `kDateFormatter`
1. Login to `Admin console`
2. Go to {nav User Management > Users}
3. Open some user for editing and change Created On date to 2 years and some days ago
4. Save user
5. Confirm Created On of edited user looks like `2 years ago`
6. Change `core/units/users/users_config.php`, line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:2', 'default' => '#NOW#'),
```
7. Refresh users' list
8. Confirm Created On of edited user looks like `2 years, 6 months ago` (months should correspond to entered value)
9. Change `core/units/users/users_config.php`, line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:3', 'default' => '#NOW#'),
```
10. Refresh users' list
11. Confirm Created On of edited user looks like `2 years, 6 months, 3 weeks ago` (values should correspond to entered value)
12. Change `core/units/users/users_config.php`, line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:4', 'default' => '#NOW#'),
```
13. Refresh users' list
14. Confirm Created On of edited user looks like `2 years, 6 months, 3 weeks, 15 hours ago` (values should correspond to entered value)
15. Change `core/units/users/users_config.php`, line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:5', 'default' => '#NOW#'),
```
16. Refresh users' list
17. Confirm Created On of edited user looks like `2 years, 6 months, 3 weeks, 15 hours, 49 minutes ago` (values should correspond to entered value)
18. Change `core/units/users/users_config.php`, line 370 to:
```
lang=php
'CreatedOn' => Array ('formatter' => 'kDateFormatter', 'format' => 'relative:6', 'default' => '#NOW#'),
```
19. Refresh users' list
20. Confirm Created On of edited user looks like `2 years, 6 months, 3 weeks, 15 hours, 50 minutes, and 20 seconds ago` (values should correspond to entered value)
# Testing `DateHelper::getHumanTime()`
1. Add method into the end of `UsersTagProcessor` class in `core/units/users/users_tag_processor.php`:
``` lang=php, name=core/units/users/users_tag_processor.php
protected function RelatedCreatedOn($params)
{
/** @var kDBItem $object */
$object = $this->getObject($params);
/** @var DateHelper $date_helper */
$date_helper = $this->Application->recallObject('DateHelper');
return $date_helper->getHumanTime(TIMENOW - $object->GetDBField('CreatedOn'), $params['level']);
}
```
2. Add tag into `core/admin_templates/users/users_edit.tpl` just before `<div id="scroll_container">`:
``` lang=html, name=core/admin_templates/users/users_edit.tpl
<inp2:u_RelatedCreatedOn level="1"/><br/>
<inp2:u_RelatedCreatedOn level="2"/><br/>
<inp2:u_RelatedCreatedOn level="3"/><br/>
<inp2:u_RelatedCreatedOn level="4"/><br/>
<inp2:u_RelatedCreatedOn level="5"/><br/>
<inp2:u_RelatedCreatedOn level="6"/><br/>
```
3. Go to {nav User Management > Users}
4. Select previously edited user and click Edit
5. Confirm you see six relative time lines just under header like:
* `2 years ago`
* `2 years, 6 months ago` (months should correspond to entered value)
* `2 years, 6 months, 3 weeks ago` (values should correspond to entered value)
* `2 years, 6 months, 3 weeks, 15 hours ago` (values should correspond to entered value)
* `2 years, 6 months, 3 weeks, 15 hours, 49 minutes ago` (values should correspond to entered value)
* `2 years, 6 months, 3 weeks, 15 hours, 50 minutes, and 20 seconds ago` (values should correspond to entered value)
It should correspond to user's `Created On`.* in IDE
1. open `core/admin_templates/users/users_edit.tpl` file for editing
2. add these lines after `<inp2:m_RenderElement name="combined_header" ...` line:
```
lang=html
<inp2:u_Field name="CreatedOn" format="relative"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:1"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:2"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:3"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:4"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:5"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:6"/><br/>
<inp2:u_Field name="CreatedOn" format="relative:7"/><br/>
---<br/>
<inp2:u_RelatedCreatedOn level="1"/><br/>
<inp2:u_RelatedCreatedOn level="2"/><br/>
<inp2:u_RelatedCreatedOn level="3"/><br/>
<inp2:u_RelatedCreatedOn level="4"/><br/>
<inp2:u_RelatedCreatedOn level="5"/><br/>
<inp2:u_RelatedCreatedOn level="6"/><br/>
<inp2:u_RelatedCreatedOn level="7"/><br/>
```
3. save changes
4. open `core/units/users/users_tag_processor.php` file for editing
5. add this method/tag in there:
```
lang=php
protected function RelatedCreatedOn(array $params)
{
/** @var kDBItem $object */
$object = $this->getObject($params);
/** @var DateHelper $date_helper */
$date_helper = $this->Application->recallObject('DateHelper');
return $date_helper->getHumanTime(abs($object->GetDBField('CreatedOn') - TIMENOW), $params['level']);
}
```
6. save changes
* in CLI:
* run the `./in-portal classmap:rebuild` command in the root folder of a project (for new PHP classes to be recognized)
* in Admin Console
1. go to {nav Configuration > Website > Regional} section
2. import `core/install/english.lang` language pack (to add new phrases)
# Testing `kDateFormatter`
1. Login to `Admin console`
2. Go to {nav User Management > Users}
3. Open any user for editing
4. change the `Created On` field to be 2 years and some days in the past
5. Save changes
6. Open the same user for editing
7. Confirm, that below the blue bar you'll see this (do the math yourself to confirm, that shown values are correct):
```
2 years ago
2 years ago
2 years, 7 months ago
2 years, 7 months, 3 weeks ago
2 years, 7 months, 3 weeks, 1 day ago
2 years, 7 months, 3 weeks, 1 day, 21 hours ago
2 years, 7 months, 3 weeks, 1 day, 21 hours, 17 minutes ago
2 years, 7 months, 3 weeks, 1 day, 21 hours, 17 minutes, and 36 seconds ago
---
2 years
2 years
2 years, 7 months
2 years, 7 months, 3 weeks
2 years, 7 months, 3 weeks, 1 day
2 years, 7 months, 3 weeks, 1 day, 21 hours
2 years, 7 months, 3 weeks, 1 day, 21 hours, 17 minutes
2 years, 7 months, 3 weeks, 1 day, 21 hours, 17 minutes, and 36 seconds
```
8. change the `Created On` field to be 2 years and some days in the future
9. Save changes
10. Open the same user for editing
11. Confirm, that below the blue bar you'll see this (do the math yourself to confirm, that shown values are correct):
```
since 1 year
since 1 year
since 1 year, 8 months
since 1 year, 8 months, 1 week
since 1 year, 8 months, 1 week, 3 days
since 1 year, 8 months, 1 week, 3 days, 2 hours
since 1 year, 8 months, 1 week, 3 days, 2 hours, 38 minutes
since 1 year, 8 months, 1 week, 3 days, 2 hours, 38 minutes, and 49 seconds
---
1 year
1 year
1 year, 8 months
1 year, 8 months, 1 week
1 year, 8 months, 1 week, 3 days
1 year, 8 months, 1 week, 3 days, 2 hours
1 year, 8 months, 1 week, 3 days, 2 hours, 38 minutes
1 year, 8 months, 1 week, 3 days, 2 hours, 38 minutes, and 49 seconds
```
# Testing `DateHelper::getShortHumanTime()`
1. Add method into the end of `PhraseTagProcessor` class in `core/units/phrases/phrase_tp.php`:
``` lang=php, name=core/units/phrases/phrase_tp.php
protected function RelatedModifiedOn($params)
{
/** @var kDBItem $object */
$object = $this->getObject($params);
/** @var DateHelper $date_helper */
$date_helper = $this->Application->recallObject('DateHelper');
return $date_helper->getShortHumanTime(TIMENOW - $object->GetDBField('LastChanged'));
}
```
2. Add tag into `core/admin_templates/languages/phrase_edit.tpl` just before `<div id="scroll_container">`:
``` lang=html, name=core/admin_templates/languages/phrase_edit.tpl
<inp2:phrases_RelatedModifiedOn/>
```
3. Go to admin console, {nav Website & Content > Labels & Phrases}
4. Select some phrase, note it's `Modified On` time and click Edit
5. Confirm you see relative time like `3d 17h 22mi 43s` just under header. It should correspond to noted `Modified On`