lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Tue, Sep 14, 2010 at 10:30 AM, soly man <luascript2010@gmail.com> wrote:
Dear friends

I have  the following lua code and i want to get the current day and
the previous day

---------------------------------------------------------------------------------

--get the system current date

dd = os.date('%Y%m%d')

print (dd)

--get the system previous date

kk = dd - 1

print (kk)

--------------------------------------------------------------------------------------


the output looks like

--20100901
--20100900

but it should look like

--20100901
--20100831

plz help me to solve this problem

thank you all


Using the luadate lib from http://luaforge.net/projects/date/ :

> require 'date'
> dd = date()
> print(dd)
Tue Sep 14 2010 10:39:56
> kk = dd:copy():adddays(-1)
> print(kk)
Mon Sep 13 2010 10:39:56
>

Robby