This PHPMaker 2024 project will show you how to display the value of DateTime field with the Description of Relative Time. There are two main available: Time Ago (time that already happened in the past), and Time Left (time that will be happened in future).
For example (first version):
- 7 days ago
- 10 bulan lagi (Indonesian)
- 5 minutes left
- etc ...
Or even you can display it as follows (second version):
- 47 minutes, 54 seconds ago
- 2 bulan, 9 hari lagi (Indonesian)
- 11 hours, 8 minutes left
- etc ...
As you can see from the second version above, we can define 2 units of relative time description that will be displayed. By default all units are displayed if we do not adjust the configuration. We can limit by 1 unit (first version) or 2 units (second version), and so forth, that suits our needs.
In addition, we can also define Time Left which means the time will be happened in future. If this time has already been reached out, then the relative time will be changed to Time Ago. You will learn how to implement this logic so easily via Server Events of PHPMaker 2024 project.
There are two main example in this project. The first one is Time Ago, which will display the records that have DateTime in the past. The second one is Time Left and Ago, which will display the records that have DateTime in the future, including the ones that its DateTime have been reached out now, so that the Relative Time will be changed from Time Left to Time Ago.
There are many things you will learn from this PHPMaker 2024 project:
- How to use the recommended and correct PHP Package to implement Relative Time from our PHPMaker 2024 project.
- How to add PHP Package from Composer Packages under Tools menu in PHPMaker 2024 project.
- How to use Namespace_Use server event that existed since PHPMaker 2024 that related to usage of PHP Package.
- How to create our own API in order to implement Relative Time that will be triggered from client-side events.
- How to create our own PHP Global Function in Global Code server event, in order to implement Relative Time from Row_Rendered server event.
- How to adjust the Configuration Setting for Relative Time in order to implement our needs, for example: how many units to be displayed, whether to use Weeks or not, which Language should be displayed, the Separator among units, and the Suffix (like ago or left, or even to hide it at all!).
- How to define our own Languages in Global Code Server Event (if have not defined, yet), in the PHP Package of that Relative Time.
- How to use Multi-Language for Relative Time by creating a new Class that extended from existing LanguageAdapter Class that belongs to the Relative Time PHP Package.
- How to separate the logic between Time Ago and Time Left so that it will automatically be adjusted by comparing the DateTime with current DateTime.
- How to check and implement the possibility of Time Left will be changed into Time Ago in future.
- How to make the connection between Client's Events with Server Events in order to implement the logic of Time Ago and Time Left.
- How to use Client Side Events under Fields setup, so that after End-Users selecting the Language and DateTime, then the description of Relative Time will be shown up immediately.
- How to move the logic from Client Side to Server Events, so that it can be simpler to writing the code in Client Side.
- How to setup Time Zone explicitly in order to process the Relative Time in Global Function and Api_Action Server Event properly.
- How to use Custom Field in order to display the Description of Relative Time without having to save it into database.
- How to prevent Deleting record and displaying the warning message to End-Users by using Row_Deleting Server Event.
- How to display the default page by using a function in Global Code server event.
- How to change the Menu Item's property by using MenuItem_Adding server event.
- How easy it is now to understand the whole application framework simply from inside PHPMaker project.