How to get current time inside Lua script?

Hello community!
I want to get current time(os.time()) and set is as parameter by using Ardupilot
Here is my pseudo-code:
– Load MAVLink library
mavlink = require(“mavlink”)

– Function to set a parameter using MAVLink
function setParameter(param_id, value)
local msg = mavlink.messages.param_set_encode(
system_id, – Your system ID
component_id, – Your component ID
param_id,
value,
mavlink.MAV_PARAM_TYPE_REAL32
)
mavlink.send_message(msg)
end

– Calculate current time in seconds since epoch
local currentTime = os.time()

– Set the “CurrentTime” parameter in ArduPilot
setParameter(“CurrentTime”, currentTime)

Please give me a tip how to do it properly