Question about time os.date ( )

Hi everyone…

This is my first time using time os.date ( )

    -- Just a text     title = display.newText( sceneGroup, "Date", 0, 0, native.systemFont, 20 )     title.x = display.contentCenterX     title.y = 40     title:setFillColor( 1, 1, 1 )          date = os.date()    -- returns table of date & time values     local function updateTime()         title.text = os.date()     end     Runtime:addEventListener( "enterFrame", updateTime )

I see y my iPad

Thu Apr 2 17:26:05 2015 – and of course the seconds are changing every second…

I have some questions…


1.- How do I do something like this

if myVariableTime == Apr 2 or myVariableTime > Apr 2 then

      – nextLevel.isVisible = true

end

So I can type myVariableTime == May 20  and the app will be running and when it counts May 20 the next level will be visible.

Kind of giving coins every 24 hours, something like that.


and also

How do I get the time that the open the app for the first time…

in another variable ,… keep counting time

and then in another say … you have been using this app for  2 months, and 3 days

something like that


I hope is not too much and I really hope someone can helpe me with this, thanks

Dates ant times are a pain in any language.

https://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Consider capturing the OS.time instead (seconds since 1970) then converting that to a date. More on EPOCH date: http://www.epochconverter.com

Snip from my displaying the date from os.time().

lblTimeNow = display.newText( os.date('%H:%M %p',os.time()), 0, 0, "HelveticaNeue-Light", 20 )lblTimeNow.x =  display.contentWidth / 2 lblTimeNow.y = 55 lblTimeNow:setFillColor( 0, 0, 0, 0.8)

You can then do simple maths < or > on the date

if (dateA \> dateB) then else end

It’s a lot!!!

But thank you for that information…

I had never hear the word EPOCH.

T read both articles, I will use more “time” to try to understand and use it on my apps

but I think I could use some of that soon.

Thanks you very much for your time!

Victor

Dates ant times are a pain in any language.

https://coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Consider capturing the OS.time instead (seconds since 1970) then converting that to a date. More on EPOCH date: http://www.epochconverter.com

Snip from my displaying the date from os.time().

lblTimeNow = display.newText( os.date('%H:%M %p',os.time()), 0, 0, "HelveticaNeue-Light", 20 )lblTimeNow.x = &nbsp;display.contentWidth / 2 lblTimeNow.y = 55 lblTimeNow:setFillColor( 0, 0, 0, 0.8)

You can then do simple maths < or > on the date

if (dateA \> dateB) then else end

It’s a lot!!!

But thank you for that information…

I had never hear the word EPOCH.

T read both articles, I will use more “time” to try to understand and use it on my apps

but I think I could use some of that soon.

Thanks you very much for your time!

Victor