Jump to content

[HELP] Time + Date


LukisLT

Recommended Posts

As you see, i made labbels for " --/--/-- " and " dd/mm/yy " and kenix's function has label to, but if this helps here is the client code :

function GetCurrentDateAndTime ( ) 
        local aRealTime = getRealTime ( ) 
        return 
            string.format ( "%04d/%02d/%02d", aRealTime.year + 1900, aRealTime.month + 1, aRealTime.monthday ), 
            string.format ( "%02d:%02d:%02d", aRealTime.hour, aRealTime.minute, aRealTime.second ) 
    end 
      
    local sDate, sTime = GetCurrentDateAndTime( ) 
    guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Time: ' .. sTime .. ' Date ' .. sDate , true ) 
     
--- --- --- --- --- 
function open() 
        if guiGetVisible ( GUIEditor_Window[1] ) then 
                guiSetVisible ( GUIEditor_Window[1], false ) 
showCursor(false) 
  guiSetInputEnabled(false) 
        else 
                guiSetVisible ( GUIEditor_Window[1], true ) 
showCursor(true) 
  guiSetInputEnabled(true) 
 end 
end 
bindKey("F2","down",open) 
  
function close() 
if (source == GUIEditor_Button[1]) then 
guiSetVisible ( GUIEditor_Window[1], false ) 
showCursor(false) 
  guiSetInputEnabled(false) 
  
   end 
end 
  
addEventHandler("onClientGUIClick",GUIEditor_Button[1],close,false) 

Link to comment
function GetCurrentDateAndTime() 
    local aRealTime = getRealTime() 
    return 
        string.format("%04d/%02d/%02d", aRealTime.year + 1900, aRealTime.month + 1, aRealTime.monthday), 
        string.format("%02d:%02d:%02d", aRealTime.hour, aRealTime.minute, aRealTime.second) 
end 
  
setTimer(function() 
local sDate, sTime = GetCurrentDateAndTime() 
guiSetText(TimeLabel, sTime) -- change TimeLabel to Your variable 
guiSetText(DateLabel, sDate) -- change DateLabel to Your variable 
end,1000,0) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...