DateTime string conversion

Hi

I just found that using v17, I can convert a datetime string including a timezone offset to a date and time. The 4D docs don’t specifically mention this, unless I’ve totally missed it.

<code 4D>
C_DATE($dDate)
C_TIME($tTime)
C_TEXT($cDateTime)

$cDateTime:=“2020-01-31T06:09:46+08:00”

$dDate:=Date($cDateTime)
$tTime:=Time($cDateTime)

</code 4D>

Note that the timezone offset part needs the colon (:slight_smile: including. The format 2020-01-31T06:09:46+0800 doesn’t work.

All good, but thought I’d post it in case it helps someone in future.

Hi Keith,
<code 4D>
$now_d:=Current date
$now_h:=Current time
$stamp_t:=String($now_d;ISO date;$now_h)+"+01:00" //France is UTC+1
in winter
ASSERT(Date($stamp_t)=$now_d)
ASSERT(Time($stamp_t)=$now_h)
</code 4D>
thanks, good to know…

: Keith WHITE

The 4D docs don’t specifically mention this, unless I’ve totally
missed it.
I completely missed it too, I think we’re supposed to see the link to String in the https://doc.4d.com/4Dv18/4D/18/Time.301-4505662.en.htmlTime> page as a nose in a middle of a face.

my god, I realise afterwards I’m speaking with a non european

my god, I realise afterwards I’m speaking with a non european

Heh! Er, still part of Europe. Just not part of EU now. :-o