KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method to Convert Time to Days and Hours/Minutes/Seconds
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: August 5, 2024

Utility method that takes in a Time value and returns an object that contains an Integer (number of days) and a Time (the remainder).

#DECLARE($time : Time)->$return_obj : Object

var $remainder_t : Time
var $days_int : Integer

$days_int:=Int($time/?24:00:00?)
$remainder_t:=$time%?24:00:00?

$return_obj:=New object("days"; $days_int; "remainder"; $remainder_t)

Here is an example of it being used:

var $timeObject : Object
$timeObject:=New object()
var $time : Time
$time:=?49:10:00? //2 days, 01:10:00 (4200 Seconds)

//Calling the utility method
$timeObject:=timeToDays($time)

ALERT(String($timeObject.days)+" days and "+String(Time($timeObject.remainder); Hour min sec))