Your code contains a smart quote and an em dash. This works: function fUTCTime local t1,t2,t3 -- this gets the current time and puts it into UTC format, i.e YYYY-MM-DDThh:mm:ssTZD put word 5 to 6 of the internet date into t3 -- we are interested in the time and time zone put the long time into t1 convert t1 to dateItems -- format is yyyy,m,d,h,m,s,day no. put (item 1 of t1) & "-" & f2digits(item 2 of t1) & "-" & f2digits(item 3 of t1) &"T" & word 1 of t3 into t2 put word 2 of t3 into t1 -- the time zone indication get char 1 of t1 -- the code for 0 (zero) is Z, apparently if it <> "+" and it <> "-" then put "Z" after t2 else put t1 after t2 end if
return t2 end fUTCTime function f2digits theNum -- add a leading zero. We don't check if there are more than two digits if number of chars of theNum = 1 then return ("0" & theNum) else return theNum end if end f2digits Bob S > On Nov 7, 2020, at 02:27 , Graham Samuel via use-livecode > <use-livecode@lists.runrev.com> wrote: > > function fUTCTime > local t1,t2,t3 > -- this gets the current time and puts it into UTC format, i.e > YYYY-MM-DDThh:mm:ssTZD > put word 5 to 6 of the internet date into t3 -- we are interested in the > time and time zone > put the long time into t1 > convert t1 to dateItems -- format is yyyy,m,d,h,m,s,day no. > put (item 1 of t1) & "-" & f2digits(item 2 of t1) & "-" & f2digits(item 3 > of t1) &"T" & word 1 of t3 into t2 > put word 2 of t3 into t1 -- the time zone indication > get char 1 of t1 — the code for 0 (zero) is Z, apparently > if it <> "+" and it <> "-“ then > put "Z" after t2 > else > put t1 after t2 > end if > return t2 > end fUTCTime > > function f2digits theNum > -- add a leading zero. We don't check if there are more than two digits > if number of chars of theNum = 1 then > return ("0" & theNum) > else > return theNum > end if > end f2digits > > >> On 7 Nov 2020, at 01:34, Alex Tweedly via use-livecode >> <use-livecode@lists.runrev.com> wrote: >> >> I don't think it "strips" the TZ info - it simply ignores it. I think the >> key phrase is in the dictionary as : >> >>> *Note:* The *convert* command assumes all dates / times are in local time >>> except for 'the seconds', which is taken to be universal time. >>> >> So it assume syou date is in local time (regardless of the +0300), and >> therefore your example returns +0000 for you (I assume you're in the UK, or >> equivalent, now). It does the same for me, and returns the date with >> "+0000". >> >> However, the same code run on my LC server (wherever on-rev is these days), >> changes the +0300 to -0500 - i.e. it's taken as local time where the server >> is. >> >> >> I assume you should be able to do something with the TimeZone library - but >> I'm struggling to figure that out. >> >>> local tNow >>> put the seconds into tNow >>> put FromUniversalTime(tNow,"US/Central") into tt >>> put tNow && tt >>> put FromUniversalTime(tNow,"US/Alaska") into tt >>> put CR & tt after msg >> gives me >> >> 1604709030 1604709030 >> >> 1604709030 >> >> so I don't have a clue what it was trying to do !?! >> >> Alex. >> >> On 06/11/2020 21:28, David Bovill via use-livecode wrote: >>> Why does: >>> >>> get "Fri, 06 Nov 2020 10:57:37 +0300" >>> convert it to internet date >>> put it >>> >>> — give >>> "Fri, 06 Nov 2020 10:57:37 +0000" >>> >>> Just seems to strip the timezone info? >>> On 30 Oct 2020, 21:29 +0000, How to use LiveCode >>> <use-livecode@lists.runrev.com>, wrote: >>>> ToUniversalTime >>> _______________________________________________ >>> use-livecode mailing list >>> use-livecode@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-livecode >> _______________________________________________ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode