Page tree
Skip to end of metadata
Go to start of metadata




Introduced in

Version:1.34

Description

Description:Returns the time difference between two date / time arrays, such as those returned by the date or systemTime commands.

Syntax

Syntax:[old_date, new_date, units] call fn_vbs_timeDifference
Parameters:
  • old_date: Array - Old date / time. The format is: [year, month, day, hour, minute, second, millisecond]. Elements left blank are set to 0.
  • new_date: Array - New date / time. The format is the same as that of old_date.
  • units: Number - Unit type to return time in:
    • 0 - years
    • 1 - months
    • 2 - days
    • 3 - hours
    • 4 - minutes (default)
    • 5 - seconds
    • 6 - milliseconds
Return Value:Number - Time difference between the two date / time arrays. Units are specified by the units parameter.

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.

Examples

Examples:
_date = date; // Store in-game date
skiptime 12; // Skip 12 hours ahead

[_date, date, 3] call fn_vbs_timeDifference;
// Result is 12

[_date, date, 2] call fn_vbs_timeDifference;
// Result is 0.5
_time = systemTime;

for "_i" from 0 to 9999 do {hint "ok"};

[_time, systemTime, 6] call fn_vbs_timeDifference;

// Returns how many milliseconds it took VBS3 to run the above code

Additional Information

See also: date, systemTime
Multiplayer: 
Problems: 

Notes






Results in units of "years" or "months" are approximations. This is because there is no definition of how many days are in "a year" or "a month". This function assumes a year is 365.25 days, and a month is (365.25/12) days.