Need system time in seconds - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Need system time in seconds - Solved

Post by DR White » Thu Aug 13, 2015 11:34 pm

I am trying to build a timer for a game. I need to subtract the start time from the finish time. I also need to display the current lapse time every second.

I have tried the following code, but it did not give me system time in seconds:

convert the date && the time to seconds
put the date && the time into field "Display"

Any suggestions would be appreciated,

David
Last edited by DR White on Fri Aug 14, 2015 12:42 pm, edited 3 times in total.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Need system time in seconds - But code does not work

Post by Dixie » Fri Aug 14, 2015 5:31 am

Code: Select all

put the seconds
This will give you the time 'now'... It might be worth you having a look at 'dateItems' in the dictionary...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Need system time in seconds - But code does not work

Post by FourthWorld » Fri Aug 14, 2015 5:34 am

"the long time" may also be useful, as it provides a readable time format that includes seconds, e.g. "9:35:51 PM".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Need system time in seconds - But code does not work

Post by DR White » Fri Aug 14, 2015 12:41 pm

Richard,

I tried "the long time" approach yesterday, but could not get it converted to seconds.
--------------------------------------------------
Dixie,

"Put the seconds" works great,

Thank each of you for your help,

David

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 157
Joined: Thu Jun 29, 2006 4:16 pm

Re: Need system time in seconds - Solved

Post by Randy Hengst » Fri Aug 14, 2015 7:21 pm

You might have already noticed this, but you can also
put the long seconds

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Need system time in seconds - Solved

Post by dunbarx » Fri Aug 14, 2015 11:32 pm

Each format has its strrngths and weaknesses, and some are subsumed by others.

But what was wrong with the "long time"?

Code: Select all

on mouseUp
   get the long time
   convert it to seconds
   answer it
end mouseUp
Craig Newman

Post Reply