zixxonx Posted January 6, 2014 Share Posted January 6, 2014 Thats function i use: local gWeekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } function FormatDate(format, escaper, timestamp) Check("FormatDate", "string", format, "format", {"nil","string"}, escaper, "escaper", {"nil","string"}, timestamp, "timestamp") escaper = (escaper or "'"):sub(1, 1) local time = getRealTime(timestamp) local formattedDate = "" local escaped = false time.year = time.year + 1900 time.month = time.month + 1 local datetime = { d = ("%02d"):format(time.monthday), h = ("%02d"):format(time.hour), i = ("%02d"):format(time.minute), m = ("%02d"):format(time.month), s = ("%02d"):format(time.second), w = gWeekDays[time.weekday+1]:sub(1, 2), W = gWeekDays[time.weekday+1], y = tostring(time.year):sub(-2), Y = time.year } for char in format:gmatch(".") do if (char == escaper) then escaped = not escaped else formattedDate = formattedDate..(not escaped and datetime[char] or char) end end return tostring(formattedDate) end firstplayed = tostring(mapinfo.map.firstplayed) firstplayed = FormatDate("d-m-Y-h-m", " ", firstplayed) lastplayed = tostring(mapinfo.map.lastplayed) lastplayed = FormatDate("d-m-Y-h-m", " ", lastplayed) outputChatBox(firstplayed) outputChatBox(lastplayed) It returns: (day).01.2014-(hour)-01 The minute is always 01! Whats the problem? Link to comment
Plean Posted January 6, 2014 Share Posted January 6, 2014 In line 2 and 4 replace the last "m" of "d-m-Y-h-m" with "i". 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