Compare date - WoWInterface
07-11-21, 03:24 PM   #1
lol_i_need_ur_help
A Murloc Raider
Join Date: Jul 2020
Posts: 5
Compare date

Hi i need to compare dates something like that:

Code:
```local currentdate = date()

*01/09/21*           *01/07/21*
if currentdate => *timespan or whatever* then

print('you should check site for updates')

end```
But i totaly not understand how to do that, can i get some help?

07-11-21, 08:38 PM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 151
Lua Code:
`local time = os.time or _G.time -- Use time API to get the timestamplocal date1 = time{ year = 2012, month = 12, day = 20, hour = 0, min = 0, sec = 0 }local date2 = time{ year = 2012, month = 12, day = 21, hour = 0, min = 0, sec = 0 } if math.floor(math.abs(date2 - date1) / (3600 * 24)) > 0 then    print("diff day")else    print("same day")end`

11-17-21, 04:24 AM   #3
lol_i_need_ur_help
A Murloc Raider
Join Date: Jul 2020
Posts: 5
Well i found solution...

If someone looking for something like that...

Lua Code:
`local function b()    local c = {year = 2022, month = 01, day = 01, hour = 00, min = 00, sec = 00}    local d = time(c)    return dend-- Compare b() with pc date.local function e()    local f = time()    return fendlocal function g()    local function h(time)    local i = floor(time / 86400)    local j = floor(mod(time, 86400) / 3600)    local k = floor(mod(time, 3600) / 60)    local l = floor(mod(time, 60))    return format("%d days:%02d hours:%02d min:%02d sec", i, j, k, l)    end    local m = b() - e()    local n = h(m)    return nendif e() >= b() then    return message("Your addon outdate!\n\n|cffFFFFFFOpen curse find|r |cff00ff52AddonName|r|cffFFFFFF. \n\ Download new update.|r")end`

 WoWInterface » Compare date

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off