Convert date from "internet" to "New York, USA" - 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

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

Convert date from "internet" to "New York, USA" - Solved

Post by DR White » Thu Jan 05, 2017 5:51 pm

How do I change "Mon, 23 Jan 2017 21:45:00 -0500" to "1/17/2017 11:45 AM" (Eastern Standard) ?

I have tried everything, even read several topics in the dictionary, without any success.

After six hours of trying, I cannot solve this problem.

Any help would be appreciated,

David
Last edited by DR White on Fri Jan 06, 2017 11:13 am, edited 2 times in total.

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

Re: Convert date from "internet" to "Eastern Standard"

Post by Klaus » Thu Jan 05, 2017 6:06 pm

Hi David,

no idea what "Eastern standard" is, but I doubt that the difference to internet date is really 6 (SIX) days! :D


Best

Klaus

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Convert date from "internet" to "Eastern Standard"

Post by SparkOut » Thu Jan 05, 2017 6:11 pm

Time conversion can be tricky, best start is to look up "set the useSystemDate to true" and the "convert" command.

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

Re: Convert date from "internet" to "Eastern Standard"

Post by DR White » Thu Jan 05, 2017 6:24 pm

Eastern standard is actually the same as New York, USA .

I just need the format to be 1/17/2017 11:45 AM form internet format.

Thanks,

David

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

Re: Convert date from "internet" to "New York, USA"

Post by Klaus » Thu Jan 05, 2017 8:10 pm

Hi David,

maybe something like this will do:

Code: Select all

...
put "Mon, 23 Jan 2017 21:45:00 -0500" into tDate
put tDate into tTime
convert tDate from internet date to short system date
convert tTime to system time
put tDate && tTime
...
But no chance this will EVER result in january 17th! :D


Best

Klaus

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

Re: Convert date from "internet" to "New York, USA"

Post by DR White » Thu Jan 05, 2017 8:16 pm

Klaus,

I am not where I can try the code today, I will tomorrow.

What does the "&&" do?

Thanks,

David

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

Re: Convert date from "internet" to "New York, USA"

Post by Klaus » Thu Jan 05, 2017 8:23 pm

Code: Select all

answer "Ask" && "the" && "dictionary" & "!"
:D

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

Re: Convert date from "internet" to "New York, USA"

Post by dunbarx » Thu Jan 05, 2017 8:59 pm

Hi.

This is just a matter of parsing your input date and time, whatever format that might be in, and rebuilding it by hand. You may want to play with the "internet date", the system date, the long date and long time, those sorts of things. You will see the various parts of these functions, and then it is just a matter of extracting the pertinent components and re-assembling. It is fun if you don't have to do it too often.

What did you use instead of "&&"? The space constant? Or perhaps " " ?

In any case, do get used to "&&". Very compact, and oftentimes you will find, especially in the above exercise, that the use of "&" and "&&" usually go together when building strings, which is exactly what you will be doing.

Craig Newman

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

Re: Convert date from "internet" to "New York, USA"

Post by DR White » Fri Jan 06, 2017 3:27 am

dunbarx,

Thanks for that explanation.

Klause,

Your date conversion code works good,

Thanks,

David

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Convert date from "internet" to "New York, USA" - Solved

Post by jacque » Fri Jan 06, 2017 5:31 pm

Or even shorter:

Code: Select all

get the internet date 
convert it to short date and time
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Convert date from "internet" to "New York, USA" - Solved

Post by Klaus » Fri Jan 06, 2017 5:36 pm

jacque wrote:Or even shorter:

Code: Select all

get the internet date 
convert it to short date and time
Yep! :D

I had something like this in mind, but used the && operator (... to date && time) which threw an error.
So AND is the magic word for convert here, thanks for the reminder!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Convert date from "internet" to "New York, USA" - Solved

Post by jacque » Fri Jan 06, 2017 6:15 pm

Alas, Klaus, your HyperCard history has left you. :D
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Convert date from "internet" to "New York, USA" - Solved

Post by Klaus » Fri Jan 06, 2017 6:43 pm

jacque wrote:Alas, Klaus, your HyperCard history has left you. :D
Well, to be honest, I don't have one! :shock:

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

Re: Convert date from "internet" to "New York, USA" - Solved

Post by dunbarx » Fri Jan 06, 2017 9:02 pm

Jacque.

True. I have never seen Klaus reference HC. I believe he has heard of it, but that is all.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Convert date from "internet" to "New York, USA" - Solved

Post by jacque » Fri Jan 06, 2017 11:32 pm

I could have sworn I'd known him since the HC list...that's how ubiquitous he is. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply