Thread Tools Display Modes
07-11-21, 03:24 PM   #1
lol_i_need_ur_help
A Murloc Raider
Join Date: Jul 2020
Posts: 7
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?
  Reply With Quote
07-11-21, 08:38 PM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Lua Code:
  1. local time = os.time or _G.time
  2.  
  3. -- Use time API to get the timestamp
  4. local date1 = time{ year = 2012, month = 12, day = 20, hour = 0, min = 0, sec = 0 }
  5. local date2 = time{ year = 2012, month = 12, day = 21, hour = 0, min = 0, sec = 0 }
  6.  
  7. if math.floor(math.abs(date2 - date1) / (3600 * 24)) > 0 then
  8.     print("diff day")
  9. else
  10.     print("same day")
  11. end
  Reply With Quote
11-17-21, 04:24 AM   #3
lol_i_need_ur_help
A Murloc Raider
Join Date: Jul 2020
Posts: 7
Well i found solution...

If someone looking for something like that...

Lua Code:
  1. local function b()
  2.     local c = {year = 2022, month = 01, day = 01, hour = 00, min = 00, sec = 00}
  3.     local d = time(c)
  4.     return d
  5. end
  6. -- Compare b() with pc date.
  7. local function e()
  8.     local f = time()
  9.     return f
  10. end
  11. local function g()
  12.     local function h(time)
  13.     local i = floor(time / 86400)
  14.     local j = floor(mod(time, 86400) / 3600)
  15.     local k = floor(mod(time, 3600) / 60)
  16.     local l = floor(mod(time, 60))
  17.     return format("%d days:%02d hours:%02d min:%02d sec", i, j, k, l)
  18.     end
  19.     local m = b() - e()
  20.     local n = h(m)
  21.     return n
  22. end
  23. if e() >= b() then
  24.     return message("Your addon outdate!\n\n|cffFFFFFFOpen curse find|r |cff00ff52AddonName|r|cffFFFFFF. \n\ Download new update.|r")
  25. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Compare date

Thread Tools
Display Modes

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