Search for Resources and Solutions

calculate_time calculates the time between two dates

The method Main.calculate_time is used in Midrub to calculate the time between two dates. I'm using same concept for the admin's panel too. 

As you maybe seen, Main.calculate_time returns always the time in minutes, hours and days. But recently i've turned it in exact date for Edit Posts in the Posts app. How this is possible? Simply, create a new method and Midrub will return two dates(server and scheduled). Use the server date and browser date to calculate the difference. After use the difference to calculate the scheduled + difference. In this way you will get the correct date, hour and minutes.

Main.calculate_time has two parameters:

  • from - contains the timestamp with time from.
  • to - contains the timestamp with the time to.

You can custom this method as i've explained before the calculate the time in hours and date(if you need).

Was this article helpful?