scratcher911 Posted September 9, 2012 Share Posted September 9, 2012 Hi. I am using getRealTime function. So if the time is 4 o'clock it shows 4. I wanna that it outputs 04 instead of 4. How? Greets: ScratcheR Link to comment
Scripting Moderators Sarrum Posted September 9, 2012 Scripting Moderators Share Posted September 9, 2012 function getGameTime ( ) local time = getRealTime ( ) local hours = time.hour local minutes = time.minute if hours < 10 then hours = "0" .. hours end return hours .. ":" .. minutes end -- outputChatBox ( getGameTime ( ) ) Link to comment
Scripting Moderators Sarrum Posted September 9, 2012 Scripting Moderators Share Posted September 9, 2012 My pleasure. Link to comment
Anderl Posted September 9, 2012 Share Posted September 9, 2012 function getGameTime ( ) local time = getRealTime ( ) local hours = time.hour local minutes = time.minute if hours < 10 then hours = "0" .. hours end return hours .. ":" .. minutes end -- outputChatBox ( getGameTime ( ) ) There is no need for that: string.format( '%02d', getRealTime().hour ) --Output: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13 and so on. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now