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:

  1. How to use the recommended and correct PHP Package to implement Relative Time from our PHPMaker 2024 project.
  2. How to add PHP Package from Composer Packages under Tools menu in PHPMaker 2024 project.
  3. How to use Namespace_Use server event that existed since PHPMaker 2024 that related to usage of PHP Package.
  4. How to create our own API in order to implement Relative Time that will be triggered from client-side events.
  5. How to create our own PHP Global Function in Global Code server event, in order to implement Relative Time from Row_Rendered server event.
  6. 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!).
  7. How to define our own Languages in Global Code Server Event (if have not defined, yet), in the PHP Package of that Relative Time.
  8. 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.
  9. 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.
  10. How to check and implement the possibility of Time Left will be changed into Time Ago in future.
  11. How to make the connection between Client's Events with Server Events in order to implement the logic of Time Ago and Time Left.
  12. 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.
  13. How to move the logic from Client Side to Server Events, so that it can be simpler to writing the code in Client Side.
  14. How to setup Time Zone explicitly in order to process the Relative Time in Global Function and Api_Action Server Event properly.
  15. How to use Custom Field in order to display the Description of Relative Time without having to save it into database.
  16. How to prevent Deleting record and displaying the warning message to End-Users by using Row_Deleting Server Event.
  17. How to display the default page by using a function in Global Code server event.
  18. How to change the Menu Item's property by using MenuItem_Adding server event.
  19. How easy it is now to understand the whole application framework simply from inside PHPMaker project.
  20. How easy and quick we can write only a few lines of PHP and Javascript/jQuery code simply from PHPMaker project.