Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting previous day's date in Lua

Tags:

lua

Can anyone kindly enlighten me on how to get previous day's date in 'YYYY-MM-DD' format using Lua?

I.E., a snippet that will return the date of the previous day from the day during which it is run.

like image 889
Dayo Avatar asked Sep 06 '25 13:09

Dayo


1 Answers

Try

print(os.date("%Y-%m-%d",os.time()-24*60*60))

Strictly speaking this is only guaranteed to work on a POSIX system, but it probably works in most systems.

like image 56
lhf Avatar answered Sep 10 '25 07:09

lhf