Compare Date and Time

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
tabbiati
Posts: 18
Joined: Sat Jul 09, 2011 3:18 pm

Compare Date and Time

Post by tabbiati » Sun Aug 14, 2011 3:25 pm

Hello to All,
i am very new to LiveCode but i love it :D ; for me it have only a problem :cry: : difficult to easy find example for all function....
Now i need some code to compare Date and Time to see if current date or time
is in an interval.
Can someone help me?
Thanks in advance.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Compare Date and Time

Post by Klaus » Sun Aug 14, 2011 3:47 pm

Hi tabbiati,

welcome to the forum! :D

Check these terms in the dictionary:
convert
dateitems
seconds

I am sure they will supply a solution to your problem!
And of course ask here if you get stuck!

And please check these stacks here:
http://www.runrev.com/developers/lesson ... nferences/

And here:
http://www.runrev.com/developers/lesson ... tutorials/
:D

Best from germany

Klaus

tabbiati
Posts: 18
Joined: Sat Jul 09, 2011 3:18 pm

Re: Compare Date and Time

Post by tabbiati » Sun Aug 14, 2011 4:27 pm

Thanks Klaus,
Wow You are a rockets to answer!
I see Your indication and now i can do some test :lol:

tabbiati
Posts: 18
Joined: Sat Jul 09, 2011 3:18 pm

Re: Compare Date and Time

Post by tabbiati » Sun Aug 14, 2011 5:00 pm

Ok, solved
Thanks Klaus!

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Compare Date and Time

Post by Klaus » Sun Aug 14, 2011 5:20 pm

Prego, amico mio :D

calvax
Posts: 9
Joined: Fri Dec 30, 2011 6:10 pm

Re: Compare Date and Time

Post by calvax » Wed Jan 04, 2012 1:32 pm

Hi Tabbiati.
I need to compare date/time too because I am programming something like scheduler/organizer and it's necessary to check if current datetime is > than deadline of event
Which format of date time it's better to use?
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Compare Date and Time

Post by bangkok » Wed Jan 04, 2012 2:04 pm

calvax wrote:Hi Tabbiati.
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks
Yes that's the way to go.

Code: Select all

put the  date into tNow
convert tNow to seconds

put "1/1/11" into tOldDate
convert tOldDate to seconds

if tNow > tOldDate then answer "After"

calvax
Posts: 9
Joined: Fri Dec 30, 2011 6:10 pm

Re: Compare Date and Time

Post by calvax » Fri Jan 06, 2012 4:04 pm

thanks

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Compare Date and Time

Post by Mag » Tue Apr 02, 2013 11:27 am

bangkok wrote:
calvax wrote:Hi Tabbiati.
I think to convert to seconds and after compare, can be good idea? Can I know how you solved?
thanks
Yes that's the way to go.

Code: Select all

put the  date into tNow
convert tNow to seconds

put "1/1/11" into tOldDate
convert tOldDate to seconds

if tNow > tOldDate then answer "After"
Great, but how to let know to LiveCode if the first item of tOldDate is a mont or a day?

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

Re: Compare Date and Time

Post by dunbarx » Tue Apr 02, 2013 2:21 pm

Hi.

In the United States, where we assume that everyone speaks English and uses our date and time format, the month would come first, then the day, then the year. I have heard that people do not always follow this format, which we cannot understand.

Anyway, look up the "useSystemDate" in the dictionary. It will point you in the direction of taking control of that format.

Craig Newman

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Compare Date and Time

Post by Mag » Tue Apr 02, 2013 4:46 pm

Thank you so much for the replay dunbarx, what I have forget to mention is that I would like to use a date to calculate the expiration time of a beta version, so I have to be certain that LiveCode understands that that date is passed whenever the user use it. So if somebody have more info to implement a unique "universal" date, I will be happy.

PS
Thank you for the useSystemDate tip, I will go to read the documentation.

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

Re: Compare Date and Time

Post by dunbarx » Tue Apr 02, 2013 7:38 pm

Hi.

Well, if you use the seconds, which is format independent, you are done. All you need are a few custom functions to do the comparisons and date translations.

Is the internet date also platform and format independent?

Craig Newman

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Compare Date and Time

Post by Mag » Wed Apr 03, 2013 2:13 am

OK, so I learnt that the useSystemDate specifies whether the date and time functions should be formatted in accordance with the user's system preferences, or in the standard format used in the United States. The default value is "false", so I guess that if I hard-code a date, it will be valid for the whole world.

Post Reply